1、校园网新视野教育二级C上机考试复习资料 V16.0(共50套题目)第1套 校园网新视野教育上机考试复习资料 1、程序填空题 #include #include 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 i
2、s :n); printf(x=%-12.6f y=%-12.6fn, x, y);2、程序修改题 #include 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(nnx=%d, y=%d, r=%ld, last=%ldnn
3、,x, y,r,t );3、程序设计题 校园网新视野教育上机考试复习资料#include #include double fun(double x)main() double x,s; printf(Input x: ); scanf(%lf,&x); s=fun(x); printf(s=%fn,s);第2套 校园网新视野教育上机考试复习资料 1、程序填空题 #include int c1,c2,c3;void fun(long n) c1 = c2 = c3 = 0; while (n) /*found*/ switch(_1_) /*found*/ case 1: c1+;_2_;/*f
4、ound*/ 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=%dn,n,c1,c2,c3);2、程序修改题 校园网新视野教育上机考试复习资料#include 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
5、);/*found*/ zero=count; return max;main() unsigned n; int zero,max; printf(nInput n(unsigned): ); scanf(%d,&n); max = fun( n,&zero ); printf(nThe result: max=%d zero=%dn,max,zero);3、程序设计题 校园网新视野教育上机考试复习资料#include double fun(int n)main() int n; double s; printf(nInput n: ); scanf(%d,&n); s=fun(n); pr
6、intf(nns=%fnn,s);第3套 校园网新视野教育上机考试复习资料 1、程序填空题 #include unsigned long fun(unsigned long n) unsigned long x=0; int t; while(n) t=n%10;/*found*/ if(t%2=_1_)/*found*/ x=_2_+t;/*found*/ n=_3_; return x;main() unsigned long n=-1; while(n99999999|n0) printf(Please input(0n100000000): ); scanf(%ld,&n); prin
7、tf(nThe result is: %ldn,fun(n);2、程序修改题 校园网新视野教育上机考试复习资料#include void fun (long s, long *t) int d; long sl=1;/*found*/ t = 0; while ( s 0) d = s%10;/*found*/ if (d%2 = 0) *t = d * sl + *t;sl *= 10; s /= 10; main() long s, t; printf(nPlease enter s:); scanf(%ld, &s); fun(s, &t); printf(The result is:
8、%ldn, t);3、程序设计题 校园网新视野教育上机考试复习资料#include void fun(char p1, char p2)main() printf(Enter s1 and s2:n) ; scanf(%s%s, s1, s2) ; printf(s1=%sn, s1) ; printf(s2=%sn, s2) ; printf(Invoke fun(s1,s2):n) ; fun(s1, s2) ; printf(After invoking:n) ; printf(%sn, s1) ;第4套 校园网新视野教育上机考试复习资料 1、程序填空题 #include #define
9、 M 3#define N 4void fun(int (*a)N) int i=0,j,find=0,rmax,c,k; while( (iM) & (!find) rmax=ai0; c=0; for(j=1; jN; j+) if(rmaxaij) /*found*/ rmax=aij; c= _1_ ; find=1; k=0; while(kM & find) /*found*/ if (k!=i & akc=rmax) find= _2_ ; k+; if(find) printf(find: a%d%d=%dn,i,c,aic);/*found*/ _3_ ; if(!find)
10、 printf(not found!n);main() int xMN,i,j; printf(Enter number for array:n); for(i=0; iM; i+) for(j=0; jN; j+) scanf(%d,&xij); printf(The array:n); for(i=0; iM; i+) for(j=0; jN; j+) printf(%3d,xij); printf(nn); fun(x);2、程序修改题 校园网新视野教育上机考试复习资料#include double fun ( int m ) double y = 1.0 ; int i ;/*foun
11、d*/ for(i = 2 ; i m ; i+)/*found*/ y -= 1 /(i * i) ; return( y ) ;main( ) int n = 5 ; printf( nThe result is %lfn, fun ( n ) ) ;3、程序设计题 校园网新视野教育上机考试复习资料#include #include int fun(int score, int m, int below)main( ) int score9 = 10, 20, 30, 40, 50, 60, 70, 80, 90 ; n = fun(score, 9, below) ; printf( n
12、Below the average score are: ) ; for (i = 0 ; i n ; i+) printf(%d , belowi) ;第5套 校园网新视野教育上机考试复习资料 1、程序填空题 #include #include #define N 5#define M 10/*found*/void fun(char (*ss) _1_, int k) int i=0 ;/*found*/ while(i _2_) /*found*/ ssik=_3_; i+; main() char xNM=Create,Modify,Sort,skip,Delete; int i; p
13、rintf(nThe original stringnn); for(i=0;iN;i+)puts(xi); printf(n); fun(x,4); printf(nThe string after deleted :nn); for(i=0; iN; i+) puts(xi); printf(n);2、程序修改题 校园网新视野教育上机考试复习资料#include #include double fun(double eps) double s,t; int n=1; s=0.0;/*found*/ t=0; while( teps) s+=t; t=t * n/(2*n+1); n+; /
14、*found*/ return(s);main() double x; printf(nPlease enter a precision: ); scanf(%lf,&x); printf(neps=%lf, Pi=%lfnn,x,fun(x);3、程序设计题 校园网新视野教育上机考试复习资料#include void fun( char *a, int n ) /* 以下代码仅供参考 */ int i=0,j,k=0; while(ak=*) k+; /* k为统计*字符个数 */ if(kn) i=n;j=k; /* 以下完成将下标为k至串尾的字符前移k-n个位置 */ main() pr
15、intf(Enter a string:n);gets(s); printf(Enter n : );scanf(%d,&n); fun( s,n ); printf(The string after deleted:n);puts(s);第6套 校园网新视野教育上机考试复习资料 1、程序填空题 #include #define N 4/*found*/void fun(int (*t)_1_ ) int i, j; for(i=1; iN; i+) for(j=0; ji; j+) /*found*/ _2_ =tij+tji;/*found*/ _3_ =0; main() int tN=
16、21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10, i, j; printf(nThe original array:n); for(i=0; iN; i+) for(j=0; jN; j+) printf(%2d ,tij); printf(n); fun(t); printf(nThe result is:n); for(i=0; iN; i+) for(j=0; jN; j+) printf(%2d ,tij); printf(n); 2、程序修改题 校园网新视野教育上机考试复习资料#include #include #include /*f
17、ound*/#define FU(m,n) (m/n)float fun(float a,float b,float c) float value; value=FU(a+b,a-b)+FU(c+b,c-b);/*found*/ Return(Value);main() float x,y,z,sum; printf(Input x y z: ); scanf(%f%f%f,&x,&y,&z); printf(x=%f,y=%f,z=%fn,x,y,z); if (x=y|y=z)printf(Data error!n);exit(0); sum=fun(x,y,z); printf(The
18、result is : %5.2fn,sum);3、程序设计题 校园网新视野教育上机考试复习资料#include void fun( char *a )main() char s81; printf(Enter a string:n);gets(s); fun( s ); printf(The string after deleted:n);puts(s);第7套 校园网新视野教育上机考试复习资料 1、程序填空题 #include #define N 3#define M 4/*found*/void fun(int (*a)N, int _1_) int i,temp ;/*found*/
19、for(i = 0 ; i _2_ ; i+) temp=a0i ;/*found*/ a0i = _3_ ; aki = temp ; main() int xMN= 1,2,3,4,5,6,7,8,9,10,11,12 ,i,j; printf(The array before moving:nn); for(i=0; iM; i+) for(j=0; jN; j+) printf(%3d,xij); printf(nn); fun(x,2); printf(The array after moving:nn); for(i=0; iM; i+) for(j=0; jN; j+) prin
20、tf(%3d,xij); printf(nn); 2、程序修改题 校园网新视野教育上机考试复习资料#include #include void fun( char t ) char c; int i, j;/*found*/ for( i = strlen( t ); i; i- ) for( j = 0; j i; j+ )/*found*/ if( tj t j + 1 ) c = tj; tj = t j + 1 ; tj + 1 = c; main() char s81; printf( nPlease enter a character string: ); gets( s ); p
21、rintf( nnBefore sorting:n %s, s ); fun( s ); printf( nAfter sorting decendingly:n %sn, s );3、程序设计题 校园网新视野教育上机考试复习资料#include #include void fun( char *ss )void main( void ) printf( nPlease enter an character string within 50 characters:n ); gets( tt ); printf( nnAfter changing, the stringn %s, tt ); f
22、un(tt) ; printf( nbecomesn %s, tt );第8套 校园网新视野教育上机考试复习资料 1、程序填空题 #include int fun(int x) int n, s1, s2, s3, t; n=0; t=100;/*found*/ while(t=_1_)/*found*/ s1=t%10; s2=(_2_)%10; s3=t/100;/*found*/ if(s1+s2+s3=_3_) printf(%d ,t); n+; t+; return n;main() int x=-1; while(x0): ); scanf(%d,&x); printf(nThe
23、 result is: %dn,fun(x);2、程序修改题 校园网新视野教育上机考试复习资料#include /*found*/void fun (long s, long t) long sl=10; s /= 10; *t = s % 10;/*found*/ while ( s 0) s = s/100; *t = s%10*sl + *t; sl = sl * 10; main() long s, t; printf(nPlease enter s:); scanf(%ld, &s); fun(s, &t); printf(The result is: %ldn, t);3、程序设计
24、题 校园网新视野教育上机考试复习资料#include #define N 16typedef struct char num10; int s; STREC;void fun( STREC a ) STREC tmp; int i,j; for(i = 0; i N; i+) for(j = i+1; j N; j+) /* 请按题目要求完成以下代码 */ main() STREC sN=GA005,85,GA003,76,GA002,69,GA004,85,GA001,91,GA007,72,GA008,64,GA006,87,GA015,85,GA013,91,GA012,64,GA014
25、,91,GA011,66,GA017,64,GA018,64,GA016,72; int i;FILE *out ; fun( s ); printf(The data after sorted :n); for(i=0;iN; i+) if( (i)%4=0 )printf(n); printf(%s %4d ,si.num,si.s); printf(n); out = fopen(out.dat,w) ; for(i=0;iN; i+) if( (i)%4=0 & i) fprintf(out, n); fprintf(out, %4d ,si.s); fprintf(out,n); f
26、close(out) ;第9套 校园网新视野教育上机考试复习资料 1、程序填空题 #include #define N 4fun(int tN, int n) int i, sum;/*found*/ _1_; for(i=0; in; i+)/*found*/ sum+=_2_ ; for(i=0; in; i+)/*found*/ sum+= tin-i-_3_ ; return sum;main() int tN=21,2,13,24,25,16,47,38,29,11,32,54,42,21,3,10,i,j; printf(nThe original data:n); for(i=0
27、; iN; i+) for(j=0; jN; j+) printf(%4d,tij); printf(n); printf(The result is: %d,fun(t,N);2、程序修改题 校园网新视野教育上机考试复习资料#include #include double funx(double x) return(2*x*x*x-4*x*x+3*x-6); double fun( double m, double n)/*found*/ int r; r=(m+n)/2;/*found*/ while(fabs(n-m)0.001) if(funx(r)*funx(n)0) m=r;els
28、e n=r;r=(m+n)/2; return r;main( ) double m,n, root; printf(Enter m n : n); scanf(%lf%lf,&m,&n); root=fun( m,n ); printf(root = %6.3fn,root);3、程序设计题 校园网新视野教育上机考试复习资料#include void fun( char *a, char *h,char *p )main() char s81,*t, *f; printf(Enter a string:n);gets(s); t=f=s; while(*t)t+; t-; while(*t=
29、*)t-; while(*f=*)f+; fun( s , f,t ); printf(The string after deleted:n);puts(s);第10套 校园网新视野教育上机考试复习资料 1、程序填空题 #include /*found*/_1_ fun(char ch)/*found*/ if (ch=0 & _2_)/*found*/ return 9- (ch-_3_); return ch ;main() char c1, c2; printf(nThe result :n); c1=2; c2 = fun(c1); printf(c1=%c c2=%cn, c1, c
30、2); c1=8; c2 = fun(c1); printf(c1=%c c2=%cn, c1, c2); c1=a; c2 = fun(c1); printf(c1=%c c2=%cn, c1, c2);2、程序修改题 校园网新视野教育上机考试复习资料#include void fun(char *p, char *b) int i, k=0; while(*p) i=1; while( i=3 & *p ) /*found*/ bk=p; k+; p+; i+; if(*p) /*found*/ bk+= ; bk=0;main() char a80,b80; printf(Enter a
31、 string: ); gets(a); printf(The original string: ); puts(a); fun(a,b); printf(nThe string after insert space: ); puts(b); printf(nn);3、程序设计题 校园网新视野教育上机考试复习资料#include #include #define N 8struct slist double s; struct slist *next;typedef struct slist STREC;double fun( STREC *h )STREC * creat( double *s) STREC *h,*p,*q; int i=0; h=p=(STREC*)malloc(sizeof(STREC);p-s=0; while(is=si; i+; p-next=q; p=q; p-next=0; return h;outlist( STREC *h) STREC *p; p=h-next; printf(head); do printf(-%4.1f,p-s);p=p-next; while(p!=0); printf(nn);main() double sN=85,76,69,85,91,72,64,87,ave; STREC *h; h=creat( s );