2022年C语言程序设计精髓编程题在线测试 .pdf
《2022年C语言程序设计精髓编程题在线测试 .pdf》由会员分享,可在线阅读,更多相关《2022年C语言程序设计精髓编程题在线测试 .pdf(35页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、#include #include int main() intaa, bb, cc; double re; printf(Input math1, English and math2:); scanf(%d,%d,%d, &aa, &bb, &cc); re = ( aa * 5 + bb * 1.5 + cc * 3.5) / 10; printf(Final score = %.2fn, re); return 0; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共
2、35 页 - - - - - - - - - #include #include int main() float re; inti, day; printf(Input length and days:); scanf(%f,%d, &re, &day); for ( i=0; i day; i+) re = re / 2; printf(length=%.5fn, re); return 0; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 35 页 - - - -
3、- - - - - #include #include int main() float re; printf(Input payment p:); scanf(%f, &re); re = re * 0.92; printf(price = %.1fn, re); return 0; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 35 页 - - - - - - - - - #include #include typedefstruct clock int hour,
4、 minute, second; CLOCK; int main() CLOCK clock1,clock2; int diff=0, hour, minute; printf(Input time one(hour, second):); scanf(%d,%d, &clock1.hour,&clock1.minute); printf(Input time two(hour, second):); scanf(%d,%d, &clock2.hour,&clock2.minute); diff = abs(clock1.hour * 60 + clock1.minute) - (clock2
5、.hour * 60 + clock2.minute); hour = floor(diff / 60); minute = diff % 60; printf(%d hour %d secondn,hour, minute); return 0; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 35 页 - - - - - - - - - #include #include intgcd(intx,int y) int r=x%y; while(r) x=y; y=r;
6、 r=x%y; return y; int main() 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 35 页 - - - - - - - - - inta,b,c,d,t; printf(Input a/b, c/d: ); scanf(%d/%d,%d/%d,&a,&b,&c,&d); if(bd) t=gcd(b,d); else t=gcd(d,b); if(a*d/tc*b/t) printf(%d/%d%d/%d,a,b,c,d); else if(a*d
7、/t=c*b/t) printf(%d/%d=%d/%d,a,b,c,d); else printf(%d/%d%d/%d,a,b,c,d); return 0; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 35 页 - - - - - - - - - #include #include int main() int year; doublecapital,rate, deposit; char n; printf(Input rate, year, capital:
8、); scanf(%lf,%d,%lf,&rate, &year,&capital ); printf(Compound interest (Y/N)?); scanf( %c,&n); if(n=n|n=N) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 35 页 - - - - - - - - - deposit=capital*(1+rate*year); else deposit=capital*pow(1+rate),year); printf(deposit
9、 = %.4fn,deposit); return 0; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 35 页 - - - - - - - - - #include #include int main() int year; doublecapital,rate,deposit; char n; printf(Input capital, year:); scanf(%lf,%d,&capital,&year); printf(Compound interest (Y
10、/N)?); scanf( %c,&n); if(year=1|year=2|year=3|year=5|year=8) switch(year) case 1:rate=0.0225; break; case 2:rate=0.0243; break; case 3:rate=0.0270; break; case 5:rate=0.0288; break; case 8:rate=0.0300; break; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 35 页
11、- - - - - - - - - if(n=n|n=N) deposit=capital*(1+rate*year); else deposit=capital*pow(1+rate),year); printf(rate = %.4f, deposit = %.4fn,rate,deposit); elseprintf(Error year!n); return 0; #include main() int man , women ,children ; printf( Man Women Childrenn ) ; for(man = 0 ; man 17 ; man+) for(wom
12、en = 0 ; women 25 ;women+) children = 30 -women -man ; if(3*man +2*women + children =50) printf(%3d%8d%8dn ,man,women ,children) ; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 35 页 - - - - - - - - - #include void main() int e10,t,d,b,i,j,a; charOK_flag=0; fo
13、r(a=10;a34;a+) d=a*a*a;b=a*a*a*a; e0=d/1000; e1=d/100%10; e2=d/10%10; e3=d%10; e4=b/100000; e5=b/10000%10; e6=b/1000%10; e7=b/100%10; e8=b/10%10; e9=b%10; for(i=0;i9;i+) for(j=i+1;jej) t=ei; ei=ej; ej=t; /if(e=0,1,2,3,4,5,6,7,8,9) for(i=0;i=9;i+) if(ei=i) OK_flag=1; continue; else OK_flag=0; break;
14、if(OK_flag) printf(age=%dn,a); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 35 页 - - - - - - - - - #include int main(void) intyn, jn, i, count = 0; printf(Input your birth year:); scanf(%d, &yn); printf(Input this year:); scanf(%d, &jn); for (i = yn; i= jn;
15、i+) if (i % 4 = 0) printf(%dn, i); count+; printf(count=%dn, count); return 0; #include int main(void) intyn, jn, i; long unsigned count = 0; printf(Input your birth year:); scanf(%d, &yn); printf(Input this year:); scanf(%d, &jn); for (i = yn; ijn; i+) if (i % 4 = 0) count = count + 366 * 24 * 60 *
16、 75; else 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 35 页 - - - - - - - - - count = count + 365 * 24 * 60 * 75; printf(The heart beats in your life: %lu, count); return 0; #include long Fact(int n); int main(void) int hundred, ten, one, m, n; for (hundred
17、= 1;hundred = 6;hundred+) for (ten = 0;ten = 6;ten+) for (one = 0;one = 6;one+) m = hundred * 100 + ten * 10 + one; n = Fact(hundred) + Fact(ten) + Fact(one); if (m = n) printf(%dn, n); return 0; long Fact(int n) inti; long s = 1; for (i = 1;i = n;i+) s *= i; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - -
18、 - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 35 页 - - - - - - - - - return(s); #include intFunc(int n); int main(void) int n1, m1; printf(Input n:); scanf(%d, &n1); if (n1 1000000) printf(Input error!n); return 0; m1 = Func(n1); printf(%dn, m1); return 0; intFunc(int n) intys, i; for (i = n; i 99;
19、 i-) if (n % i = 0 &i 1000) ys = i; break; returnys; #include intGcd(int a, int b); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 14 页,共 35 页 - - - - - - - - - int main(void) int n1, m1, n2, m2, ys; printf(Input m,n:); scanf(%d,%d, &m1, &n1); if (m1 10000) printf(In
20、put error!n); return 0; ys = Gcd(m1, n1); n2 = n1 / ys; m2 = m1 / ys; printf(%d/%dn, m2, n2); return 0; intGcd(int a, int b) intys, i, temp; if (a 0; i-) if (a % i = 0 & b % i = 0) ys = i; break; returnys; # include intSumPrime(int n) inti; int k; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - -
21、 - - 名师精心整理 - - - - - - - 第 15 页,共 35 页 - - - - - - - - - int sum=0; for(i=2;i=n;+i ) for(k=2;ki;+k) if(i%k=0) break; if(k = i) sum+= k; return sum; int main (void) int n; int sum; printf(Input n:); scanf(%d,&n); sum=SumPrime(n); printf(sum=%dn,sum); return 0; #include #include double Y(double x, in
22、t n); int main(void) int n1; double x1, jieg; printf(Please input x and n:); scanf(%lf,%d, &x1, &n1); jieg = Y(x1, n1); printf(Result=%.2fn, jieg); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 16 页,共 35 页 - - - - - - - - - return 0; double Y(double x, int n) double
23、 sum = 0; inti; for (i = 0; i n; i+) sum = sqrt(sum + x); return sum; #include int Sum(int n); int main(void) int n1, jieg; printf(Please input n:); scanf(%d, &n1); if (n1 0; i-) m1 = m1 + i; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 17 页,共 35 页 - - - - - - - -
24、- return m1; #include int Monkey(int n, int x); int main(void) int n1, gs1 = 1, gs2; printf(Input days n:); scanf(%d, &n1); gs2 = Monkey(n1, gs1); printf(x=%dn, gs2); return 0; int Monkey(int n, int x) inti, sum = 1; for (i = n - 1; i 0; i-) sum = (sum + x) * 2; return sum; #include int main() intc,
25、d; floatw,p; printf(Input payment:); scanf(%f,&p); if(p=1000) c=10; else c=p/100; switch(c) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 18 页,共 35 页 - - - - - - - - - case 0: d=0; break; case 1: d=5; break; case 2: case 3: case 4: d=8; break; case 5: case 6: case 7
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年C语言程序设计精髓编程题在线测试 2022 语言程序设计 精髓 编程 在线 测试
限制150内