二级C上机考试复习资料.doc

二级C上机考试复习资料.doc

呼和浩特市聪智职业培训学校 内部资料 请勿外传 PAGE PAGE 1 本资料仅供考前复习使用,请勿带入考场 聪智·学校二级C上机考试复习资料 V16.0 (共50套题目) 第1套 聪智·学校上机考试复习资料 1、程序填空题 #include stdio.h #include math.h double fun(double x) { double f, t; int n; f = 1.0 + x; /**********found**********/ t = ___1___; n = 1; do { n++; /**********found**********/ t *= (-1.0)*x/___2___; f += t; } /**********found**********/ while (___3___ = 1e-6); return f; } main() { double x, y; x=2.5; y = fun(x); printf(\nThe result is :\n); printf(x=%-12.6f y=%-12.6f\n, x, y); } 2、程序修改题 聪智·学校上机考试复习资料 #include stdio.h long fun(int x,int y,long *p ) { int i; long t=1; /**************found**************/ for(i=1; iy; i++) t=t*x; *p=t; /**************found**************/ t=t/1000; return t; } main() { long t,r; int x,y; printf(\nInput x and y: ); scanf(%ld%ld,x,y); t=fun(x,y,r); printf(\n\nx=%d, y=%d, r=%ld, last=%ld\n\n,x, y,r,t ); } 3、程序设计题 聪智·学校上机考试复习资料 #include stdio.h #include math.h double fun(double x) { } main() { double x,s; printf(Input x: ); scanf(%lf,x); s=fun(x); printf(s=%f\n,s); } 第2套 聪智·学校上机考试复习资料 1、程序填空题 #include stdio.h int c1,c2,c3; void fun(long n) { c1 = c2 = c3 = 0; while (n) { /**********found**********/ switch(___1___) { /**********found**********/ case 1: c1++;___2___; /**********found**********/ case 2: c2++;___3___; case 3: c3++; } n /= 10; } } main() { long n=123114350L; fun(n); printf(\nThe result :\n); printf(n=%ld c1=%d c2=%d c3=%d\n,n,c1,c2,c3); } 2、程序修改题 聪智·学校上机考试复习资料 #include stdio.h int fun(unsigned n, int *zero) { int count=0,max=0,t; do { t=n%10; /**************found**************/ if(t=0) count++; if(maxt) max=t; n=n/10; }while(n); /**************found**************/ zero=count; return max; } main() { unsigned n; int zero,max; printf(\nInput n(unsign

文档评论(0)

1亿VIP精品文档

相关文档