《浙江大学城市学院C语言期末上机考试题库之一》由会员分享,可在线阅读,更多相关《浙江大学城市学院C语言期末上机考试题库之一(41页珍藏版)》请在人人文库网上搜索。
1、浙江大学城市学院C语言期末上机考试题库之一20021程序填空,不要改变与输入输出有关的语句。输入一个正整数repeat (0int main(void)int repeat, ri;double x, y; scanf(%d, &repeat);for(ri = 1; ri int main(void)int celsius, fahr; scanf(“%d”,&fahr);celsius=5.0*(fahr-32)/9;printf(celsius = %dn, celsius);20023程序填空,不要改变与输入输出有关的语句。输入存款金额 money、存期 year 和年利率 rate,。
2、根据下列公式计算存款到期时的利息 interest(税前),输出时保留2位小数。interest = money(1+rate)year - money输入输出示例:括号内为说明输入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)-m。
3、oney;printf(interest = %.2fn, interest);20024程序填空,不要改变与输入输出有关的语句。输入一个正整数repeat (0= 0时,f(x) = x0.5,当x小于0时,f(x) = (x+1)2 + 2x + 1/x。输入输出示例:括号内是说明输入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;。
4、 ri =0) y=sqrt(x);else y=pow(x+1),2)+2*x+1/x;printf(f(%.2f) = %.2fn, x, y); 20025程序填空,不要改变与输入输出有关的语句。输入一个正整数repeat (0int main(void)int repeat, ri;double x, y;scanf(%d, &repeat);for(ri = 1; ri int main(void)int num1, num2; scanf(%d%d, &num1,&num2);printf(%d + %d = %dn, num1, num2, num1+num2);printf(%。
5、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程序填空,不要改变与输入输出有关的语句。计算表达式 1 + 2 + 3 + . + 100的值。输出示例:sum = 5050#include int main(void) int i, sum;sum=0;for(i=1;ii。
6、nt main(void) int i, m, sum;int repeat, ri;scanf(%d, &repeat);for(ri = 1; ri int main(void) int i, m, n;int repeat, ri;double sum;scanf(%d, &repeat);for(ri = 1; ri int main(void) int i, n;int repeat, ri;double sum;scanf(%d, &repeat);for(ri = 1; ri int main(void)int flag, i, n, t;int repeat, ri;doubl。
7、e item, sum;scanf(%d, &repeat);for(ri = 1; ri int main(void) int lower, upper;int repeat, ri;double celsius, fahr; scanf(%d, &repeat);for(ri = 1; ri int main(void)int i, n;int repeat, ri;double mypow, x;scanf(%d, &repeat);for(ri = 1; ri #include int main(void)int i, n;double mypow;scanf(%d, &n);for(。
8、i=0;iint main(void)int i, n;double myfact;double fact(int n);scanf(%d, &n);for(i=1;i#include int main(void)int i;double sum;sum=0;for(i=100;i#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。
9、(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程序填空,不要改变与输入输出有关的语句。输入一个正整数 repeat (0 0输入输出示例:括号内是说明输入3 (repeat=3)10 (x=10)0 (x=0)-98 (x=-98)输出sign(10) = 1 (x = 10时 y = 1)sign(0) = 0 (x = 0时 y = 0)sign(-98) = -1 (x = -98时y 。
10、= -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程序填空,不要改变与输入输出有关的语句。输入10个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数。输入输出示例:括号内是说明输入Reold 123?输出letter = 5, blank = 1, digit = 3, other = 1#include in。
11、t main(void)char c;int blank, digit, i, letter, other;blank = digit = letter = other = 0; for(i = 1; i = a & c = A & c =0&cint main(void)char ch;int repeat, ri;scanf(%d, &repeat);for(ri = 1; ri int main(void)int choice, i;double price;for(i = 1; i int main(void)0int i, mark;for(i = 1; i =60) printf(。
12、“Passn”);else printf(“Failn”);30007程序填空,不要改变与输入输出有关的语句。输入一个正整数 repeat (0#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, 。
13、perimeter);elseprintf(These sides do not correspond to a valid trianglen);return 0;30008程序填空,不要改变与输入输出有关的语句。输入一个正整数 repeat (0int main(void)int repeat, ri;double rate, salary, tax;scanf(%d, &repeat);for(ri = 1; ri int main(void)int i, mark, n;int na, nb, nc, nd, ne;scanf(%d,&n);na = nb = nc = nd = ne。
14、 = 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(Number of D(60-69): %dn, nd);printf(Number of E(0-59): %dn, ne);30010程序填空,不要改变与输入输出有关的语句。输入一个正整数repeat (0int main(void)char sign;int x, y;int repeat, ri;scanf(%d,&repeat);for(ri = 1;ri int main(void)int gcd, lcm, m, n; int repeat, ri; scanf(%d, &repeat);for(ri = 1; ri #include int main(void)int denominator, flag。