浙江大學(xué)C程題庫(kù)(更新).doc
《浙江大學(xué)C程題庫(kù)(更新).doc》由會(huì)員分享,可在線閱讀,更多相關(guān)《浙江大學(xué)C程題庫(kù)(更新).doc(181頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
_c語(yǔ)言程序設(shè)計(jì)題目及答案 20021程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:輸入 x,計(jì)算并輸出下列分段函數(shù) f(x) 的值(保留1位小數(shù))。當(dāng) x 不等于0時(shí),y = f(x) = 1/x,當(dāng) x 等于0時(shí),y = f(x) = 0。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入2 (repeat=2)10 (x=10)0 (x=0)輸出f(10.00) = 0.1f(0.00) = 0.0#include int main(void) int repeat, ri; double x, y; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%lf, &x); /*-*/ if(x!=0) y=1/x;else y=0; printf(f(%.2f) = %.1fn, x, y); 20022程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入華氏溫度,輸出對(duì)應(yīng)的攝氏溫度。計(jì)算公式:c = 5*(f-32)/9,式中:c表示攝氏溫度,f表示華氏溫度。輸入輸出示例:括號(hào)內(nèi)為說(shuō)明輸入150 (fahr=150)輸出celsius = 65#include int main(void)int celsius, fahr; /*-*/scanf(“%d”,&fahr); celsius=5.0*(fahr-32)/9; printf(celsius = %dn, celsius); 20023程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入存款金額 money、存期 year 和年利率 rate,根據(jù)下列公式計(jì)算存款到期時(shí)的利息 interest(稅前),輸出時(shí)保留2位小數(shù)。interest = money(1+rate)year - money輸入輸出示例:括號(hào)內(nèi)為說(shuō)明輸入1000 3 0.025 (money = 1000, year = 3, rate = 0.025)輸出interest = 76.89#include #include int main(void) int money, year;double interest, rate;/*-*/scanf(“%d%d%lf”,&money,&year,&rate); interest=money*pow(1+rate),year)-money; printf(interest = %.2fn, interest); 20024程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat= 0時(shí),f(x) = x0.5,當(dāng)x小于0時(shí),f(x) = (x+1)2 + 2x + 1/x。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入3 (repeat=3)10-0.50輸出f(10.00) = 3.16f(-0.50) = -2.75f(0.00) = 0.00#include #include int main(void) int repeat, ri; double x, y; scanf(%d, &repeat); for(ri = 1; ri =0) y=sqrt(x);else y=pow(x+1),2)+2*x+1/x; printf(f(%.2f) = %.2fn, x, y); 20025程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:輸入實(shí)數(shù) x,計(jì)算并輸出下列分段函數(shù) f(x) 的值,輸出時(shí)保留1位小數(shù)。當(dāng) x 不等于10時(shí),y = f(x) = x,當(dāng) x 等于10時(shí),y = f(x) = 1/x。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入2 (repeat=2)10234輸出f(10.0) = 0.1f(234.0) = 234.0#include int main(void) int repeat, ri; double x, y; scanf(%d, &repeat);for(ri = 1; ri = repeat; ri+) /*-*/scanf(%lf, &x);if(x!=10) y=x;else y=1/x; printf(f(%.1f) = %.1fn, x, y); 20026程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入2個(gè)整數(shù) num1 和 num2,計(jì)算并輸出它們的和、差、積、商與余數(shù)。輸出兩個(gè)整數(shù)的余數(shù)可以用 printf(%d % %d = %dn, num1, num2, num1%num2);輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入5 3 (num1=5,num2=3)輸出5 + 3 = 85 - 3 = 25 * 3 = 155 / 3 = 15 % 3 = 2#include int main(void)int num1, num2; /*-*/scanf(%d%d, &num1,&num2); printf(%d + %d = %dn, num1, num2, num1+num2); printf(%d - %d = %dn, num1, num2, num1-num2); printf(%d * %d = %dn, num1, num2, num1*num2); printf(%d / %d = %dn, num1, num2, num1/num2); printf(%d % %d = %dn, num1, num2, num1%num2); return 0;20031程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。計(jì)算表達(dá)式 1 + 2 + 3 + . + 100的值。輸出示例:sum = 5050 #include int main(void) int i, sum;/*-*/sum=0;for(i=1;i=100;i+) sum=sum+i; printf(sum = %dn, sum); 20032程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:輸入一個(gè)正整數(shù)m(0=m=100),計(jì)算表達(dá)式 m + (m+1) + (m+2) + . + 100的值。輸入輸出示例:括號(hào)內(nèi)為說(shuō)明輸入3 (repeat=3)0 (計(jì)算0+1+2+.+100)10 (計(jì)算10+11+12+.+100)50 (計(jì)算50+51+52+.+100)輸出sum = 5050sum = 5005sum = 3825 #include int main(void) int i, m, sum; int repeat, ri; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%d, &m); /*-*/ sum=0; for(i=m;i=100;i+) sum=sum+i; printf(sum = %dn, sum); 20033程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:輸入2個(gè)正整數(shù) m 和 n(m=n),計(jì)算表達(dá)式 1/m + 1/(m+1) + 1/(m+2) + . + 1/n的值,輸出時(shí)保留3位小數(shù)。輸入輸出示例:括號(hào)內(nèi)為說(shuō)明輸入3 (repeat=3)5 15 (計(jì)算1/5+1/6+1/7+.+1/15)10 20 (計(jì)算1/10+1/11+1/12+.+1/20)1 3 (計(jì)算1+1/2+1/3)輸出sum = 1.235sum = 0.769sum = 1.833 #include int main(void) int i, m, n; int repeat, ri; double sum; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%d%d, &m, &n); /*-*/ sum=0; for(i=m;i=n;i+) sum=sum+1.0/i; printf(sum = %.3fn, sum); 20034程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:輸入一個(gè)正整數(shù) n,計(jì)算表達(dá)式 1 + 1/3 + 1/5 + . 的前 n 項(xiàng)之和,輸出時(shí)保留6位小數(shù)。輸入輸出示例:括號(hào)內(nèi)為說(shuō)明輸入2 (repeat=2)5 (計(jì)算1+1/3+1/5+1/7+1/9)23 (計(jì)算1+1/3+1/5+.+1/45)輸出sum = 1.787302sum = 2.549541 #include int main(void) int i, n; int repeat, ri; double sum; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%d, &n);/*-*/ sum=0; for(i=1;i=n;i+) sum=sum+1.0/(2*i-1); printf(sum = %.6fn, sum); 20035程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:讀入一個(gè)正整數(shù) n,計(jì)算11/41/71/10的前 n 項(xiàng)之和,輸出時(shí)保留3位小數(shù)。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入2 (repeat=2)310輸出sum = 0.893sum = 0.819 #include int main(void) int flag, i, n, t; int repeat, ri; double item, sum; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%d, &n);/*-*/ sum=0;flag=1;item=0;t=1; for(i=1;i=n;i+) item=flag*1.0/t;sum=sum+item;flag=-flag;t=t+3; printf(sum = %.3fn, sum); 20036程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:讀入2個(gè)整數(shù) lower 和 upper,輸出一張華氏攝氏溫度轉(zhuǎn)換表,華氏溫度的取值范圍是lower, upper,每次增加2F。計(jì)算公式:c = 5 * (f - 32) / 9,其中:c表示攝氏溫度,f表示華氏溫度。輸出請(qǐng)使用語(yǔ)句 printf(%3.0f %6.1fn, fahr, celsius);輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入2 (repeat=2)32 35 (lower=32,upper=35)40 30 (lower=40,upper=30)輸出fahr celsius 32 0.0 34 1.1fahr celsius#include int main(void) int lower, upper; int repeat, ri; double celsius, fahr; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%d%d, &lower, &upper); printf(fahr celsiusn); /*-*/for(fahr=lower;fahr=upper;fahr=fahr+2) celsius=5 * (fahr- 32) / 9; printf(%3.0f %6.1fn, fahr, celsius); 20037程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:輸入2 個(gè)正整數(shù) m 和 n,計(jì)算 m!n!。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入:2 (repeat=2)1 4 (m=1,n=4)3 8 (m=3,n=8)輸出:1! + 4! = 253! + 8! = 40326#include stdio.hint main(void) int i, m, n; int repeat, ri; double fm, fn; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%d%d, &m, &n);/*-*/ fm=fn=1; for(i=1;i=m;i+) fm=fm*i; for(i=1;i=n;i+) fn=fn*i; printf(%d! + %d! = %.0fn, m, n, fm+fn); 20038程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:讀入1 個(gè)實(shí)數(shù)x和正整數(shù) n(n=50),計(jì)算并輸出 x 的 n 次冪(保留2位小數(shù)),不允許調(diào)用pow函數(shù)求冪。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入2 (repeat=2)1.5 2 (x=1.5,n=2)2 7 (x=2,n=7)輸出2.25128.00 #include int main(void) int i, n; int repeat, ri; double mypow, x; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%lf%d, &x, &n); /*-*/ mypow=1; for(i=1;i=n;i+) mypow = mypow*x; printf(%.2fn, mypow); 20041程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)n,生成一張3的乘方表,輸出30 3n的值,可調(diào)用冪函數(shù)計(jì)算3的乘方。輸出使用語(yǔ)句 printf(pow(3,%d) = %.0fn, i, mypow);輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入3 (n=3)輸出pow(3,0) = 1pow(3,1) = 3pow(3,2) = 9pow(3,3) = 27#include #include int main(void) int i, n; double mypow; scanf(%d, &n);/*-*/for(i=0;i=n;i+) mypow=pow(3,i); printf(pow(3,%d) = %.0fn, i, mypow); return 0;20042程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)n,生成一張階乘表,輸出 1! n! 的值,要求定義和調(diào)用函數(shù)fact(n)計(jì)算 n!,函數(shù)類型為double。輸出使用語(yǔ)句 printf(%d! = %.0fn, i, myfact);輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入3 (n=3)輸出1! = 12! = 23! = 6 #include int main(void) int i, n; double myfact; double fact(int n); scanf(%d, &n);/*-*/for(i=1;i=n;i+) myfact=fact(i); printf(%d! = %.0fn, i, myfact); return 0;/*-*/double fact(int n) int i;double f=1;for(i=1;i=n;i+)f=f*i;return f; 20043程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:輸入2個(gè)正整數(shù) m 和 n(m=n),計(jì)算 n! /(m!* (n-m)!) 。要求定義并調(diào)用函數(shù)fact(n)計(jì)算n的階乘, 其中 n 的類型是 int,函數(shù)類型是 double。例:括號(hào)內(nèi)是說(shuō)明輸入:2 (repeat=2)2 7 (m=2, n=7)5 12 (m=5, n=12)輸出:result = 21result = 792#include stdio.hdouble fact(int n);int main(void) int m, n; int repeat, ri; double s; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%d%d, &m, &n);/*-*/ s= fact(n)/(fact(m)*fact(n-m); printf(result = %.0fn, s);return 0;/*-*/double fact(int n) int i;double f=1;for(i=1;i=n;i+)f=f*i;return f; 20044程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。計(jì)算 1000.51010.510000.5的值(保留2位小數(shù)),可調(diào)用sqrt函數(shù)計(jì)算平方根。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸出sum = 20435.99#include #include int main(void) int i; double sum; /*-*/ sum=0; for(i=100;i=1000;i+) sum=sum+sqrt(i); printf(sum = %.2fn, sum);30001程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù)repeat (0repeat10),做repeat次下列運(yùn)算:輸入?yún)?shù)a,b,c,求一元二次方程a*x*xb*xc0的根,結(jié)果保留2位小數(shù)。輸出使用以下語(yǔ)句:printf(參數(shù)都為零,方程無(wú)意義!n);printf(a和b為0,c不為0,方程不成立n);printf(x = %0.2fn, -c/b);printf(x1 = %0.2fn, (-b+sqrt(d)/(2*a);printf(x2 = %0.2fn, (-b-sqrt(d)/(2*a);printf(x1 = %0.2f+%0.2fin, -b/(2*a), sqrt(-d)/(2*a);printf(x2 = %0.2f-%0.2fin, -b/(2*a), sqrt(-d)/(2*a);輸入輸出示例:括號(hào)內(nèi)為說(shuō)明輸入:5 (repeat=5)0 0 0 (a=0,b=0,c=0)0 0 1 (a=0,b=0,c=1)0 2 4 (a=0,b=2,c=4)2.1 8.9 3.5 (a=2.1,b=8.9,c=3.5)1 2 3 (a=1,b=2,c=3)輸出:參數(shù)都為零,方程無(wú)意義!a和b為0,c不為0,方程不成立x = -2.00x1 = -0.44x2 = -3.80x1 = -1.00+1.41ix2 = -1.00-1.41i#include #include int main(void) int repeat, ri; double a, b, c, d; scanf(%d, &repeat); for(ri = 1; ri =0)printf(x1 = %0.2fn, (-b+sqrt(d)/(2*a);printf(x2 = %0.2fn, (-b-sqrt(d)/(2*a); else printf(x1 = %0.2f+%0.2fin, -b/(2*a), sqrt(-d)/(2*a);printf(x2 = %0.2f-%0.2fin, -b/(2*a), sqrt(-d)/(2*a); 30002程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù) repeat (0repeat10),做 repeat 次下列運(yùn)算:輸入一個(gè)整數(shù) x,計(jì)算并輸出下列分段函數(shù) sign(x) 的值。 -1 x 0 輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入3 (repeat=3) 10 (x=10) 0 (x=0) -98 (x=-98) 輸出sign(10) = 1 (x = 10時(shí) y = 1)sign(0) = 0 (x = 0時(shí) y = 0)sign(-98) = -1 (x = -98時(shí)y = -1)#include int main(void) int repeat, ri; int x, y; scanf(%d, &repeat); for(ri = 1; ri 0) y=1;else if(x=0) y=0;else y=-1; printf(sign(%d) = %dn, x, y);return 0;30003程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入10個(gè)字符,統(tǒng)計(jì)其中英文字母、空格或回車、數(shù)字字符和其他字符的個(gè)數(shù)。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入Reold 123?輸出letter = 5, blank = 1, digit = 3, other = 1#include int main(void) char c; int blank, digit, i, letter, other; blank = digit = letter = other = 0; for(i = 1; i = a & c = A & c =0&c=9) digit +; else if(c = | c = n) blank +; else other +; printf(letter = %d, blank = %d, digit = %d, other = %dn, letter, blank, digit, other);return 0;30004程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù) repeat (0repeat10),做 repeat 次下列運(yùn)算:輸入五級(jí)制成績(jī)(AE),輸出相應(yīng)的百分制成績(jī)(0100)區(qū)間,要求使用switch語(yǔ)句。五級(jí)制成績(jī)對(duì)應(yīng)的百分制成績(jī)區(qū)間為:A(90-100)、B(80-89)、C(70-79)、D(60-69)和E(0-59),如果輸入不正確的成績(jī),顯示Invalid input。輸出使用以下語(yǔ)句:printf(90-100n); printf(80-89n); printf(70-79n); printf(60-69n);printf(0-59n);printf(Invalid inputn); 輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入6ABCDEj (repeat=6,輸入的五級(jí)成績(jī)分別為A、B、C、D、E和無(wú)效的字符j) 輸出90-10080-8970-7960-690-59Invalid input (輸入數(shù)據(jù)不合法)#include int main(void) char ch; int repeat, ri; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) ch = getchar(); /*-*/ switch(ch) case A: printf(90-100n);break; case B: printf(80-89n);break; case C : printf(70-79n);break;case D : printf(60-69n);break;case E : printf(0-59n); break; default: printf(Invalid inputn); break; return 0;30005程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。查詢水果的單價(jià)。有4種水果,蘋果(apples)、梨(pears)、桔子(oranges)和葡萄(grapes),單價(jià)分別是3.00元/公斤,2.50元/公斤,4.10元/公斤和10.20元/公斤。在屏幕上顯示以下菜單(編號(hào)和選項(xiàng)),用戶可以連續(xù)查詢水果的單價(jià),當(dāng)查詢次數(shù)超過(guò)5次時(shí),自動(dòng)退出查詢;不到5次時(shí),用戶可以選擇退出。當(dāng)用戶輸入編號(hào)14,顯示相應(yīng)水果的單價(jià)(保留1位小數(shù));輸入0,退出查詢;輸入其他編號(hào),顯示價(jià)格為0。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入3 (oranges的編號(hào)) 0 (退出查詢) 輸出1 apples2 pears3 oranges4 grapes0 Exitprice = 4.11 apples2 pears3 oranges4 grapes0 Exit#include int main(void) int choice, i; double price; for(i = 1; i = 5; i+) printf(1 applesn); printf(2 pearsn); printf(3 orangesn); printf(4 grapesn); printf(0 Exitn); scanf(%d, &choice); if(choice = 0) break; else/*-*/ switch (choice) case 1: price=3.0; break; case 2: price=2.5; break; case 3: price=4.1; break; case 4: price=10.2; break; default: price=0.0; break; printf(price = %0.1fn, price); return 0;30006程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入5個(gè)學(xué)生的數(shù)學(xué)成績(jī),判斷他們的成績(jī)是否及格。如果成績(jī)低于60,輸出Fail,否則,輸出Pass。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入6159924060輸出PassFailPassFailPass#include int main(void)0 int i, mark; for(i = 1; i =60) printf(“Passn”); else printf(“Failn”); 30007程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù) repeat (0repeat10),做 repeat 次下列運(yùn)算:輸入三角形的3條邊 a, b, c,如果能構(gòu)成一個(gè)三角形,輸出面積 area 和周長(zhǎng) perimeter(保留2位小數(shù));否則,輸出These sides do not correspond to a valid triangle。在一個(gè)三角形中,任意兩邊之和大于第三邊。三角形面積計(jì)算公式:area = (s(s-a)(s-b)(s-c)0.5 ,其中s = (a+b+c)/2輸出使用以下語(yǔ)句:printf(area = %.2f, perimeter = %.2fn,area, perimeter);printf(These sides do not correspond to a valid trianglen); 輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入2 (repeat=2) 5 5 3 (a=5,b=5,c=3)1 4 1 (a=1,b=4,c=1)輸出area = 7.15, perimeter = 13.00These sides do not correspond to a valid triangle#include #include int main(void) int a, b, c; int repeat, ri; double area, perimeter, s; scanf(%d, &repeat); for(ri = 1; ri c&b+ca&c+ab) perimeter=a+b+c; s= perimeter/2;area=sqrt(s*(s-a)*(s-b)*(s-c);printf(area = %.2f, perimeter = %.2fn,area, perimeter); else printf(These sides do not correspond to a valid trianglen);return 0; 30008程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù) repeat (0repeat10),做 repeat 次下列運(yùn)算:輸入一個(gè)職工的月薪 salary,輸出應(yīng)交的個(gè)人所得稅 tax(保留2位小數(shù))。計(jì)算公式:tax = rate * (salary - 850)當(dāng) salary 850 時(shí),rate = 0當(dāng) 850 salary 1350 時(shí),rate = 5%當(dāng) 1350 salary 2850 時(shí),rate = 10%當(dāng) 2850 salary 5850 時(shí),rate = 15%當(dāng) 5850 salary 時(shí),rate = 20% 輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入5 (repeat=5)1010.87 (salary=1010.87)32098.76 (salary=32098.76)800 (salary=800)4010 (salary=4010)2850 (salary=2850)輸出tax = 8.04tax = 6249.75tax = 0.00tax = 474.00tax = 200.00#include int main(void) int repeat, ri; double rate, salary, tax; scanf(%d, &repeat); for(ri = 1; ri = repeat; ri+) scanf(%lf, &salary);/*-*/ if(salary=850) rate=0; else if(salary=1350) rate=0.05; else if(salary=2850) rate=0.1; else if(salary=5850) rate=0.15; else rate=0.2; tax = rate * (salary - 850); printf(tax = %0.2fn, tax); 30009程序填空,不要改變與輸入輸出有關(guān)的語(yǔ)句。輸入一個(gè)正整數(shù) n,再輸入 n 個(gè)學(xué)生的百分制成績(jī),統(tǒng)計(jì)各等級(jí)成績(jī)的個(gè)數(shù)。成績(jī)等級(jí)分為五級(jí),分別為A(90-100)、B(80-89)、C(70-79)、D(60-69)和E(0-59)。輸入輸出示例:括號(hào)內(nèi)是說(shuō)明輸入5 (n=5)77 54 92 73 60輸出Number of A(90-100): 1Number of B(80-89): 0Number of C(70-79): 2Number of D(60-69): 1Number of E(0-59): 1#include int main(void) int i, mark, n; int na, nb, nc, nd, ne; scanf(%d,&n); na = nb = nc = nd = ne = 0; for(i = 1; i =90) na+;else if(mark =80) nb+;else if(mark =70) nc+;else if(mark =60) nd+;else ne+; printf(Number of A(90-100): %dn, na); printf(Number of B(80-89): %dn, nb); printf(Number of C(70-79): %dn, nc); printf(Nu- 1.請(qǐng)仔細(xì)閱讀文檔,確保文檔完整性,對(duì)于不預(yù)覽、不比對(duì)內(nèi)容而直接下載帶來(lái)的問(wèn)題本站不予受理。
- 2.下載的文檔,不會(huì)出現(xiàn)我們的網(wǎng)址水印。
- 3、該文檔所得收入(下載+內(nèi)容+預(yù)覽)歸上傳者、原創(chuàng)作者;如果您是本文檔原作者,請(qǐng)點(diǎn)此認(rèn)領(lǐng)!既往收益都?xì)w您。
下載文檔到電腦,查找使用更方便
32 積分
下載 |
- 配套講稿:
如PPT文件的首頁(yè)顯示word圖標(biāo),表示該P(yáng)PT已包含配套word講稿。雙擊word圖標(biāo)可打開word文檔。
- 特殊限制:
部分文檔作品中含有的國(guó)旗、國(guó)徽等圖片,僅作為作品整體效果示例展示,禁止商用。設(shè)計(jì)者僅對(duì)作品中獨(dú)創(chuàng)性部分享有著作權(quán)。
- 關(guān) 鍵 詞:
- 浙江大學(xué) 題庫(kù) 更新
鏈接地址:http://m.appdesigncorp.com/p-1638254.html