二级C完全修正版.doc

二级C语言上机考试复习资料 (共0套题目)第1套 1、程序填空题#includestdio.h void fun(char *s, int *t) { int i, n;n=0; /**********found**********/for(i=0; ___1___ !=0; i++) /**********found**********/if(s[i]=0s[i]= ___2___ ) n++; /**********found**********/___3___ ; } main() { char s[80]=abcdef35adgh3kjsdf7;int t;printf(\nThe original string is : %s\n,s);fun(s,t);printf(\nThe result is : %d\n,t); } 2、程序修改题 #include stdio.h int fun(int *x,int y) { int t ; /**************found**************/ t = x ; x = y ; /**************found**************/ return(y) ; } main() { int a = 3, b = 8 ;printf(%d %d\n, a, b) ; b = fun(a, b) ; printf(%d %d\n, a, b) ; }3、程序设计题 #include stdio.h void fun (int *a, int *n) {} main( ) { int aa[1000], n, k ;fun ( aa, n ) ;for ( k = 0 ; k n ; k++ )if((k + 1) % 10 == 0) printf(\n) ;else printf(%5d, aa[k]) ; } 第2套 1、程序填空题#include stdio.h void fun(char *s, char *p) { int i, j, n, x, t;n=0;for(i=0; s[i]!=\0; i++) n++;for(i=1; in-2; i=i+2) { /**********found**********/___1___; /**********found**********/for(j=___2___+2 ; jn; j=j+2)if(s[t]s[j]) t=j;if(t!=i){ x=s[i]; s[i]=s[t]; s[t]=x; }}for(i=1,j=0; in; i=i+2, j++) p[j]=s[i]; /**********found**********/p[j]=___3___; } main() { char s[80]=baawrskjghzlicda, p[50];printf(\nThe original string is : %s\n,s);fun(s,p);printf(\nThe result is : %s\n,p); }2、程序修改题 #include math.h #include stdio.h float fun ( float num ) { int s ;float n, t, pi ;t = 1 ; pi = 0 ; n = 1 ; s = 1 ; /**************found**************/while(t = num){pi = pi + t ;n = n + 2 ;s = -s ; /**************found**************/t = s % n ;}pi = pi * 4 ;return pi ; } main( ) { float n1, n2 ;printf(Enter a float number: ) ;scanf(%f, n1) ;n2 = fun(n1) ;printf(%6.4f\n, n2) ; }3、程序设计题 #include stdio.h #include string.h #define LEN 20 void fun (char a[], char b[], int n) {} main( ) { char str1[LEN], str2[LEN] ;int n ;printf(Enter the string:\n) ;gets(str1) ;printf(Enter the index of the char deleted:) ;scanf(

文档评论(0)

1亿VIP精品文档

相关文档