杭電acm問題詳解無敵版_第1頁
杭電acm問題詳解無敵版_第2頁
杭電acm問題詳解無敵版_第3頁
已閱讀5頁,還剩47頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、選修課考試作業(yè)2012素?cái)?shù)判定 392014青年歌手大獎(jiǎng)賽評(píng)委會(huì)打分402017字符串統(tǒng)計(jì)472019數(shù)列有序! 482020絕對(duì)值排序 502033人見人愛A+B 542039三角形 562040親和數(shù) 57:春杰級(jí):電商141001 Sum ProblemProblem Descripti onHey, welcome to HDOJ(Ha ngzhou Dianzi Uni versity On li ne Judge).In this problem, your task is to calculate SUM( n) = 1 + 2 + 3 + . + n.In putThe in

2、put will con sist of a series of in tegers n, one in teger per line.OutputFor each case, output SUM( n) in one line, followed by a bla nk line. You may assume the result will be in the range of 32-bit sig ned in teger.Sample In put1100Sample Output15050AuthorDOOM III解答:#i nclude<stdio.h>mai n(

3、)int n , i , sumsum =0;while( scanf("%d",&n)!二 1)sum=0;for(i =0; i <=n; i +)sum +=i ;printf ("%dnn" , sum);1089 A+B for In put-O utput Practice(I)Problem Descripti onYour task is to Calculate a + b.Too easy?! Of course! I specially desig ned the problem for acm beg inn ers

4、.You must have found that some problems have the same titles with this one, yes, all these problems were desig ned for the same aim.In putThe in put will con sistof a series of pairs of in tegers a and b, separated by a space,one pair of in tegers per line.OutputFor each pair of in put in tegers a a

5、nd b you should output the sum of a and b in one line, and with one line of output for each line in in put.Sample In put1 510 20Sample Output630AuthorlcyRecomme ndJGShi ning解答:#i nclude<stdio.h>main ()int a, b;while (sca nf("%d%d"&a,&b)!= EOF printf ("%dn",a+b);1090

6、 A+B for Input-Output Practice(II)Problem Descripti onYour task is to Calculate a + b.In putIn put contains an in teger N in the first line, and the n N lines follow. Each line con sists of a pair of in tegers a and b, separated by a space, one pair of in tegers per line.OutputFor each pair of in pu

7、t in tegers a and b you should output the sum of a and b in one line, and with one line of output for each line in in put.Sample In put21 510 20Sample Output630AuthorlcyRecomme ndJGSh ining解答:#i nclude<stdio.h>#defi ne M 1000void main ()int a , b, n,j M, i ;/prin tf("please in put n:n&quo

8、t;); scanf ("%d", &n);for (i =0; i <n; i +)sca nf("%d%d: & a,& b);/prin tf("%d %d",a,b);j i = a+b;i =0;while (i <n)printf("%d" :ji);i +;printf("n");1091 A+B for In put-0 utput Practice(III)Problem Descripti onYour task is to Calculate a

9、+ b.In putIn put contains multiple test cases. Each test case contains a pair of in tegers aand b, one pair of in tegers per line. A test case containing 0 0 term in atesthe inputand this test case is not to be processed.OutputFor each pair of in put in tegers a and b you should output the sum of a

10、and b in one line, and with one line of output for each line in in put.Sample In put1 510 200 0Sample Output630AuthorlcyRecomme ndJGShi ning解答:#i nclude<stdio.h>main ()int a, b;scanf ("%d %d",& a,& b); while (!( a=0&&D=0)printf ("%dn", a+b); scanf("%d %

11、d",&a,&b);1092 A+B for lnput-0 utput Practice(IV)Problem Descripti onYour task is to Calculate the sum of some in tegers.In putIn put contains multiple test cases. Each test case contains a in teger N, and the nN in tegers follow in the sameli ne. A test case starti ng with 0 termi nate

12、s the input and this test case is not to be processed.OutputFor each group of in put in tegers you should output their sum in one line, and with one line of output for each line in in put.Sample In put4 1 2 3 45 1 2 3 4 50Sample Output1015AuthorlcyRecomme ndJGShi ning解答:#i nclude <stdio.h>int

13、main ()int n , sum i, t;while(sca nf("%d", &n)!= EO&&n!= 0)sum=0;for(i =0; i <n; i +)scanf("%d",&t);sum =sum+t;printf ("%dn",sum);1093 A+B for In put-Output Practice(V)Problem Descripti onYour task is to calculate the sum of some in tegers.In putIn pu

14、t contains an in teger N in the first line, and the n N lines follow. Each line starts with a integer M, and then M integers follow in the same line.OutputFor each group of in put in tegers you should output their sum in one line, and with one line of output for each line in in put.Sample In put24 1

15、 2 3 45 1 2 3 4 5Sample Output1015Authorlcy解答:#i nclude<stdio.h>mai n()int n , a, b, i, j, sumsum =0;while(sca nf("%dn", &n)!=- 1)for (i =0; i <n; i +)scanf("%d", &b);for(j =0; j <b; j +)scanf("%d",&a);sum+=a;printf("%dn",sum);sum =0;10

16、94 A+B for Input-Output Practice(VI)Problem Descripti onYour task is to calculate the sum of some in tegers.In putIn put contains multiple test cases, and one case one line. Each case starts withan integer N, and then N integers follow in the same line.OutputFor each test case you should output the

17、sum of N in tegers in one line, and withone line of output for each line in in put.Sample In put4 1 2 3 45 1 2 3 4 5Sample Output1015AuthorlcyRecomme ndJGShi ning解答:#i nclude<stdio.h>mai n()int n , a, b, i, j, sumsum =0;while (sca nf("%dn", &n)!=- 1) for(j =0;j <n;j+)scanf(&qu

18、ot;%d",&a);sum+=a;printf("%dn",sum);sum =0;Save to FileCopy to Clipboard 1095 A+B for lnput-0 utput Practice(VII)Problem Descripti onYour task is to Calculate a + b.In putThe in put will con sist of a series of pairs of in tegers a and b, separated by a space, one pair of in teger

19、s per line.OutputFor each pair of in put in tegers a and b you should output the sum of a and b, and followed by a bla nk line.Sample In put1 510 20Sample Output630AuthorlcyRecomme ndJGShi ning解答:#i nclude<stdio.h>main ()int a, b;while (sca nf("%d%d"&a,&b)!= EOF printf ("

20、;%dnn" , a+b);1096 A+B for In put-Output Practice(VIII)Problem Descripti onYour task is to calculate the sum of some in tegers.In putIn put contains an in teger N in the first line, and the n N lines follow. Each line starts with a integer M, and then M integers follow in the same line.OutputFo

21、r each group of in put in tegers you should output their sum in one line, and you must note that there is a bla nk line betwee n outputs.Sample In putSample Output10AuthorIcyRecomme ndJGShi ning解答:int main ()int a, b, i ,j,l1000, k; scanf ("%d",&i);getchar ();for (j =1;j <=i ;j +)l

22、j=0;for (j =1;j <=i ;j +)sca nf("%d",&a);getchar ();for (k=1; k<=a; k+)scanf("%d", &b);getchar();l j+=b;for (j =1;j <=i -1; j+)printf ("%dnn" , l j ); printf ("%dn", l i );2000 ASCII碼排序Problem Descripti on輸入三個(gè)字符后,按各字符的ASCII碼從小到大的順序輸出這三個(gè)字符。In p

23、ut輸入數(shù)據(jù)有多組,每組占一行,有三個(gè)字符組成,之間無空格。Output對(duì)于每組輸入數(shù)據(jù),輸出一行,字符中間用一個(gè)空格分開。Sample In putqweasdzxcSample Outpute q wa d sc x zAuthorIcySourcec語言程序設(shè)計(jì)練習(xí)(一)Recomme ndJGShi ning解答:#i nclude<stdio.h>mai n()char a , b, c, d;while (seanf("%c %c %c",&a,&b,&c)!= EOF getchar ();if (a>=b)if (c

24、>=a)printf ("%c %c %cn", b, a, c);else if (b>=c)printf ("%c %c %cn", c, b, a);else if (b<c)printf ("%c %c %cn", b, c, a);elseif (c>=b)printf ("%c %c %cn", a, b, c);else if (c>=a)printf ("%c %c %cn", a, c, b);else if (a>c)printf (&qu

25、ot;%c %c %cn", c, a, b);2001計(jì)算兩點(diǎn)間的距離Problem Descripti on輸入兩點(diǎn)坐標(biāo)(X1,Y1) , (X2,Y2),計(jì)算并輸出兩點(diǎn)間的距離。數(shù)據(jù)之間用空格In put輸入數(shù)據(jù)有多組,每組占一行,由4個(gè)實(shí)數(shù)組成,分別表示x1,y1,x2,y2,隔開。Output對(duì)于每組輸入數(shù)據(jù),輸出一行,結(jié)果保留兩位小數(shù)。Sample In puto o o 1o 1 1 oSample Output1.001.41AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(一)Recomme ndJGShi ning解答:#i nclude<stdio.h&g

26、t;#in clude<math.h>mai n()double a , b, c, d, s;while (sca nf("%lf %lf %lf %lf",&a,&b,&c,&d)!= EOFs =sqrt ( a- c)*( a-c)+( b- d)*( b- d);printf ("%.2lfn" , s);2002計(jì)算球體積Problem Descripti on根據(jù)輸入的半徑值,計(jì)算球的體積。In put輸入數(shù)據(jù)有多組,每組占一行,每行包括一個(gè)實(shí)數(shù),表示球的半徑。Output輸出對(duì)應(yīng)的球的體積,對(duì)于

27、每組輸入數(shù)據(jù),輸出一行,計(jì)算結(jié)果保留三位小數(shù)。Sample In put11.5Sample Output4.18914.137Hint#define PI 3.1415927AuthorlcySourceC語言程序設(shè)計(jì)練習(xí)(一)Recomme ndJGShi ning解答:#i nclude<stdio.h>#define PI 3.1415927mai n()double a, v;while (scanf("%lf",&a)!= EOFv =4* PI* a* a* a/3;printf ("%.3lfn" , v);2003求

28、絕對(duì)值Problem Descripti on數(shù)的絕對(duì)值。In put輸入數(shù)據(jù)有多組,每組占一行,每行包含一個(gè)實(shí)數(shù)。Output對(duì)于每組輸入數(shù)據(jù),輸出它的絕對(duì)值,要求每組數(shù)據(jù)輸出一行,結(jié)果保留兩位小數(shù)。Sample In put123-234.00Sample Output123.00234.00AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(一)Recomme ndJGShi ning解答:#i nclude<stdio.h>mai n()double a;while (scanf("%lf",&a)!= EOFif (a<0)a =-a;pr

29、intf ("%.2lfn" , a);2004成績轉(zhuǎn)換Problem Descripti on輸入一個(gè)百分制的成績t,將其轉(zhuǎn)換成對(duì)應(yīng)的等級(jí),具體轉(zhuǎn)換規(guī)則如下:90100 為 A;8089 為 B;7079 為 C;6069 為 D;059 為 E;In put輸入數(shù)據(jù)有多組,每組占一行,由一個(gè)整數(shù)組成。Output對(duì)于每組輸入數(shù)據(jù),輸出一行。如果輸入數(shù)據(jù)不在 0100圍,請(qǐng)輸出一行:"Score is error!Sample In put5667100123Sample OutputEDAScore is error!AuthorlcySourcec語言程序設(shè)

30、計(jì)練習(xí)(一)Recomme ndJGShi ning解答:#in elude <stdio.h>int main ()int n;while (seanf("%d",&n)!= EOFif (n> 100| n<O)printf else if(n>=90)printfelse if(n>=80)printfelse if(n>=70)printfelse if(n>=60)printfelse printf ("En");return 0;("Score is error!' n

31、");("An");("Bn");("Cn");("Dn");2005第幾天?Problem Deseripti on給定一個(gè)日期,輸出這個(gè)日期是該年的第幾天。In putsample in put , 另輸入數(shù)據(jù)有多組,每組占一行,數(shù)據(jù)格式為YYYY/MM/D組成,具體參見外,可以向你確保所有的輸入數(shù)據(jù)是合法的。Output對(duì)于每組輸入數(shù)據(jù),輸出一行,表示該日期是該年的第幾天。Sample In put1985/1/202006/3/12Sample Output2071AuthorIcySourcec

32、語言程序設(shè)計(jì)練習(xí)(一)Recomme ndJGShi ning解答:#i nclude<stdio.h>mai n()int a, b, c, d, e, f, g;while (scanf ("%d/%d/%d "& a,& b,&c)!= EOF if (b=1)d=c;else if (b=2)d=31+c;else if (b=3)d=31+28+c;else if(b=4)d =31+28+31+c;else if(b=5)d=31+31+28+30+c;else if(b=6)d =31+28+31+30+31+c;else

33、if(b=7)d=31+28+31+30+31+30+c;else if(b=8)d=31+28+31+30+31+30+31+c;else if(b=9)d=31+28+31+30+31+30+31+31+c;else if (b=10)d=31+28+31+30+31+30+31+31+30+c;else if(b=11)d =31+28+31+30+31+30+31+31+30+31+c;else if(b=12)d =31+28+31+30+31+30+31+31+30+31+c+30;e=a%l00;f =a%400;g =a%4;if (e=0)if(f =0)d=1+d;else

34、d=d;else if (g=0)d =d+1;elsed =d;printf ("%dn",d);2006求奇數(shù)的乘積Problem Descripti on給你n個(gè)整數(shù),求他們中所有奇數(shù)的乘積。In putn,表示本組數(shù)據(jù)輸入數(shù)據(jù)包含多個(gè)測試實(shí)例,每個(gè)測試實(shí)例占一行,每行的第一個(gè)數(shù)為 共有n個(gè),接著是n個(gè)整數(shù),你可以假設(shè)每組數(shù)據(jù)必定至少存在一個(gè)奇數(shù)。Output輸出每組數(shù)中的所有奇數(shù)的乘積,對(duì)于測試實(shí)例,輸出一行。Sample In put3 1 2 34 2 3 4 5Sample Output315AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(一)Recomme

35、 ndJGShi ning解答:#i nclude<stdio.h>mai n()int n , s, i , a;while(sca nf("%d", &n)!= EOFs =1;for (i =0; i <n; i +)scanf("%d",&a);if(a2=1)s =s* a;else;printf ("%dn",s);2007平方和與立方和Problem Descripti on給定一段連續(xù)的整數(shù),求出他們中所有偶數(shù)的平方和以及所有奇數(shù)的立方和。m和n組成。In put輸入數(shù)據(jù)包含多組測試實(shí)

36、例,每組測試實(shí)例包含一行,由兩個(gè)整數(shù)Output對(duì)于每組輸入數(shù)據(jù),輸出一行,應(yīng)包括兩個(gè)整數(shù) 數(shù)的平方和以及所有奇數(shù)的立方和。你可以認(rèn)為32位整數(shù)足以保存結(jié)果。x和y,分別表示該段連續(xù)的整數(shù)中所有偶Sample In put1 32 5Sample Output4 28 20 152AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(一)Recomme ndJGShi ning解答:#i nclude<stdio.h>int main ()int suml, sum2 n, i , mt;while(sca nf("%d%d"&m &n )!= EO

37、Fsum1 =sum2=0;if (n>n)t=mm= n; n =t;for (i =m i <=n; i +)if(i %2=0) sum1+=(i *i);elsesum2+=(i *i *i);printf ("%d %dn", sum1 sum2;return 0;2008數(shù)值統(tǒng)計(jì)Problem Descripti on統(tǒng)計(jì)給定的n個(gè)數(shù)中,負(fù)數(shù)、零和正數(shù)的個(gè)數(shù)。In put輸入數(shù)據(jù)有多組,每組占一行,每行的第一個(gè)數(shù)是整數(shù)n (n<100),表示需要統(tǒng)計(jì)的數(shù)值 的個(gè)數(shù),然后是n個(gè)實(shí)數(shù);如果n=0,則表示輸入結(jié)束,該行不做處理。Output對(duì)于每組輸

38、入數(shù)據(jù),輸出一行a,b和c,分別表示給定的數(shù)據(jù)中負(fù)數(shù)、零和正數(shù)的個(gè)數(shù)。Sample In put6 0 1 2 3 -1 05 1 2 3 4 0.50Sample Output1 2 30 0 5AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(二)Recomme ndJGShi ning解答:#i nclude<stdio.h>int main ()int n , i , b1, b2, b3;double a 101;while(scanf ("%d",& n)!= EOF&& n != 0)for (i =0; i <n;

39、i +) scanf ("%lf" ,&a i ); b1 =b2=b3=0;for (i =0; i <n; i +)if(ai <0) b1 +;else if(a i=0) b2 +;elseb3 +;printf("%d %d %dn", b1, b2, b3);2009求數(shù)列的和Problem Descripti on數(shù)列的定義如下:數(shù)列的第一項(xiàng)為n,以后各項(xiàng)為前一項(xiàng)的平方根,求數(shù)列的前m項(xiàng)的和。In putn和m的含義2位小數(shù)。輸入數(shù)據(jù)有多組,每組占一行,由兩個(gè)整數(shù)n (n<10000)和m(m<1000組成,

40、如前所述。Output對(duì)于每組輸入數(shù)據(jù),輸出該數(shù)列的和,每個(gè)測試實(shí)例占一行,要求精度保留Sample In put81 42 2Sample Output94.733.41AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(二)Recomme ndJGShi ning解答:#i nclude<stdio.h>#in clude<math.h>mai n()double n , m s, w, i;while(scanf("%lf%lf" ,&n,&m)!= EOFs =n;for (i =1; i <n; i +)n=sqrt (

41、n);s=s+n;printf ("%.2lfn", s);2010水仙花數(shù)Problem Descripti on春天是鮮花的季節(jié),水仙花就是其中最迷人的代表,數(shù)學(xué)上有個(gè)水仙花數(shù),他是這樣定義的:“水仙花數(shù)”是指一個(gè)三位數(shù),它的各位數(shù)字的立方和等于其本身,比如:153=1人3+5人3+3人3?,F(xiàn)在要求輸出所有在 m和n圍的水仙花數(shù)。In put輸入數(shù)據(jù)有多組,每組占一行,包括兩個(gè)整數(shù)m和n (100<=m<=*=999。Output對(duì)于每個(gè)測試實(shí)例,要求輸出所有在給定圍的水仙花數(shù), 就是說,輸出的水仙花數(shù)必須大于 等于m,并且小于等于n,如果有多個(gè),則要求從小

42、到大排列在一行輸出, 之間用一個(gè)空格隔 開;如果給定的圍不存在水仙花數(shù),則輸出no;每個(gè)測試實(shí)例的輸出占一行。Sample In put100 120300 380Sample Outputno370 371AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(二)Recomme ndJGShi ning解答:#i nclude<stdio.h>mai n()int m, n, i , w a, b, c, j , s, d;while (scanf ("%d %d", & n,& n)!= EOF =0; =1;(n>n)=m =n;=wel

43、sefor (i =m)i <=n; i +)a=i/100;b=i/10%0;c=i%0;s=a*a*a+b*b*b+c*c*c;if (i =s)if(d!=0)printf("");printf("%d",i);d=d+1;j=j+1;if (j =1)printf("non");elseprintf("n");2011多項(xiàng)式求和Problem Descripti on多項(xiàng)式的描述如下:1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + .現(xiàn)在請(qǐng)你求出該多項(xiàng)式的前n項(xiàng)的和。In put輸

44、入數(shù)據(jù)由2行組成,首先是一個(gè)正整數(shù)m(m<1O0,表示測試實(shí)例的個(gè)數(shù),第二行包含個(gè)正整數(shù),對(duì)于每一個(gè)整數(shù)(不妨設(shè)為n,* 1000 ),求該多項(xiàng)式的前 n項(xiàng)的和。Output對(duì)于每個(gè)測試實(shí)例 n,要求輸出多項(xiàng)式前 n項(xiàng)的和。每個(gè)測試實(shí)例的輸出占一行,結(jié)果保留 2位小數(shù)。Sample In put21 2Sample Output1.000.50AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(二)Recomme ndJGShi ning解答:#i nclude<stdio.h>#in clude<math.h>mai n()double m, n, i , s,

45、j, k, a;while (scanf("%lf",&n)!= EOF for (i =0; i <m)i +)s =0;scanf("%lf",&n);for(j =1;j <=n;j+)=s+1/j *pow(- 1, j +1);printf("%.2lfn", s);2012素?cái)?shù)判定Problem Descripti on對(duì)于表達(dá)式nA2+n+41,當(dāng)n在(x,y )圍取整數(shù)值時(shí)(包括 x,y ) (-39<=x<y<=50),判定該 表達(dá)式的值是否都為素?cái)?shù)。In put輸入數(shù)據(jù)

46、有多組,每組占一行,由兩個(gè)整數(shù)x,y組成,當(dāng)x=0,y=0時(shí),表示輸入結(jié)束,該行不做處理。Output"OK",否則請(qǐng)輸出“ Sorry ”,每對(duì)于每個(gè)給定圍的取值,如果表達(dá)式的值都為素?cái)?shù),則輸出 組輸出占一行。Sample In puto 1o oSample OutputOKAuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(二)Recomme ndJGShi ning解答:#i nclude<stdio.h>mai n()int x , y, i ,j ,s, k, w d;while(scanf("%d%d"&x,&y)

47、=2&&(x!=0| y!= 0)w =0;for (i =x; i <=y; i +)k=i *i +i +41;for(j =2; j <k; j +)d=k%;if(d=0)w+;if(w=0)printf("OKn");elseprintf("Sorryn");2014青年歌手大獎(jiǎng)賽評(píng)委會(huì)打分Problem Descripti on青年歌手大獎(jiǎng)賽中,評(píng)委會(huì)給參賽選手打分。選手得分規(guī)則為去掉一個(gè)最高分和一個(gè)最低分, 然后計(jì)算平均得分,請(qǐng)編程輸出某選手的得分。In put輸入數(shù)據(jù)有多組,每組占一行,每行的第一個(gè)數(shù)是 n(2

48、<n<100),表示評(píng)委的人數(shù),然后是 n個(gè)評(píng)委的打分。Output對(duì)于每組輸入數(shù)據(jù),輸出選手的得分,結(jié)果保留2位小數(shù),每組輸出占一行。Sample In put3 99 98 974 100 99 98 97Sample Output98.0098.50AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(三)Recomme ndlcy解答:#i nclude<stdio.h>int main ()int n , s, a 100, i, k, b;double w;while (sca nf("%d", &n)!= EOF k=0;w =0;

49、s=0;for (i =0; i <n; i +)scanf ("%d",&a i );k+;b=a 0;w=w+a i;for (i =0; i <k; i +)if(ai>s)s=a i;for(i =1; i <k; i +)if(b>ai)b =ai ;w =(w-s-b)/( k- 2);printf("%.2lfn", w);2015偶數(shù)求和Problem Descripti on有一個(gè)長度為n(n<=100)的數(shù)列,該數(shù)列定義為從 2開始的遞增有序偶數(shù),現(xiàn)在要求你按照 順序每m個(gè)數(shù)求出一個(gè)平均值,

50、如果最后不足 m個(gè),則以實(shí)際數(shù)量求平均值。編程輸出該平均值序列。In put輸入數(shù)據(jù)有多組,每組占一行,包含兩個(gè)正整數(shù)n和m, n和m的含義如上所述。Output對(duì)于每組輸入數(shù)據(jù),輸出一個(gè)平均值序列,每組輸出占一行。Sample In put3 24 2Sample Output3 63 7AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(三)Recomme ndIcy解答:#i nclude<stdio.h>mai n()int n , m a, b, i, j , k, w I, e, s, d, r; while(sca nf("%d%d"& n,

51、&m)!= EOFs=0;e=0;l=0;if(n<=n)for s e kprintf elsewr forsleif k e if printf printfr(i =0; i <n; i +)=s+2; =e+s; =e/ n;("%dn",k);=n%m=0;(i =1; i <=n-w i +)=s+2; =l +s;=e+s;(i %m=0)=e/m)=0;(r)(""); ("%d", k);=r+1; s if forse=0;(w!= 0)(j =0;j <n; j +)=s+2;=e

52、+s;d=e-1;k=d/ wprintf("");printf("%d", k);printf("n");2016數(shù)據(jù)的交換輸出Problem Descripti on輸入n(n<100)個(gè)數(shù),找出其中最小的數(shù),將它與最前面的數(shù)交換后輸出這些數(shù)。In put輸入數(shù)據(jù)有多組,每組占一行,每行的開始是一個(gè)整數(shù)n,表示這個(gè)測試實(shí)例的數(shù)值的個(gè)數(shù),跟著就是n個(gè)整數(shù)。n=0表示輸入的結(jié)束,不做處理。Output對(duì)于每組輸入數(shù)據(jù),輸出交換后的數(shù)列,每組輸出占一行。Sample In put4 2 1 3 45 5 4 3 2 10Sample Output1 2 3 41 4 3 2 5AuthorlcySourcec語言程序設(shè)計(jì)練習(xí)(三)Recomme ndIcy解答:#i nclude<stdio.h>mai n()int n , a 100, i , j, k, s, w;while (sca nf("%d", &n)!= EO&&n!= 0) j =0;for (i =0; i <n

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論