收藏 分享(赏)

全国计算机二级考试C语言模拟试题(一).doc

上传人:s36f12 文档编号:7526836 上传时间:2019-05-20 格式:DOC 页数:67 大小:3.01MB
下载 相关 举报
全国计算机二级考试C语言模拟试题(一).doc_第1页
第1页 / 共67页
全国计算机二级考试C语言模拟试题(一).doc_第2页
第2页 / 共67页
全国计算机二级考试C语言模拟试题(一).doc_第3页
第3页 / 共67页
全国计算机二级考试C语言模拟试题(一).doc_第4页
第4页 / 共67页
全国计算机二级考试C语言模拟试题(一).doc_第5页
第5页 / 共67页
点击查看更多>>
资源描述

1、11套 每一套题目都是按照“填空题-改错题-编程题”顺序排列, 填空题上面带有两个划线的是人工做题时候多余划线,不要理睬!#include #include #define N 10double fun(double *x) int i, j; double av, yN;av=0;/*found*/for(i=0; ivoid fun ( char *s, int num5 ) int k, i=5;for ( k = 0; k= 0)numi+;main( ) char s181; int num15, i;printf( “nPlease enter a string: “ ); get

2、s( s1 );fun ( s1, num1 );for ( i=0; i 3#define M 4#define N 5int fun ( int aMN )int tot=0,i,j;for(i=0;i#define N 4/*found*/void fun(int _tN_ , int n) int i,s;/*found*/for(i=0; i #define N 10/*found*/int fun(int a, int m ) int low=0,high=N-1,mid;while(low amid)low=mid+1;else return(mid);return(-1);ma

3、in() int i,aN=-3,4,7,9,13,45,67,89,100,180 ,k,m;printf(“a数组中的数据如下:“);for(i=0;i=0) printf(“m=%d,index=%dn“,m,k);else printf(“Not be found!n“);编程题6#include void fun( char *a, char *p )char *q=a;int j=0;while(*q struct aa *next; NODE;int fun(NODE *h) int sum = 0 ;NODE *p;/*found*/p=h-next;while(p) if(p

4、-data%2=0)sum +=p-data;/*found*/p=p-next;return sum;NODE *creatlink(int n) NODE *h, *p, *s;int i;h=p=(NODE *)malloc(sizeof(NODE);for(i=1; idata=rand()%16;s-next=p-next;p-next=s;p=p-next;8p-next=NULL;return h;outlink(NODE *h, FILE *pf) NODE *p;p = h-next;fprintf(pf ,“nnTHE LIST :nn HEAD “ );while(p)

5、fprintf(pf ,“-%d “,p-data ); p=p-next; fprintf (pf,“n“);outresult(int s, FILE *pf) fprintf(pf,“nThe sum of even numbers : %dn“,s);main() NODE *head; int even;head=creatlink(12);head-data=9000;outlink(head , stdout);even=fun(head);printf(“nThe result :n“); outresult(even, stdout);编程题#include #include

6、 #define N 80int fun(char *str)int i,j = strlen(str);for(i=0;i#include #define N 6typedef struct node int data;struct node *next; NODE;void fun(NODE *h) NODE *p, *q; int t;p = h;while (p) /*found*/q = _p-next_ ;/*found*/while (_q _)10 if (p-data q-data) t = p-data; p-data = q-data; q-data = t; q = q

7、-next;/*found*/p = _ p-next _ ;NODE *creatlist(int a) NODE *h,*p,*q; int i;h=NULL;for(i=0; idata=ai;q-next = NULL;if (h = NULL) h = p = q;else p-next = q; p = q; return h;void outlist(NODE *h) NODE *p;p=h;if (p=NULL) printf(“The list is NULL!n“);else printf(“nHead “);do printf(“-%d“, p-data); p=p-ne

8、xt; while(p!=NULL);printf(“-Endn“);main() NODE *head;int aN= 0, 10, 4, 2, 8, 6 ;head=creatlist(a);printf(“nThe original list:n“);outlist(head);fun(head);printf(“nThe list after inverting :n“);outlist(head);改错题11#include #include void fun (char *s)/*found*/while(*s) if(*s=A for(i=p+1;i#define N 5type

9、def struct student long sno;char name10;float score3;13 STU;void fun(char *filename, STU n) FILE *fp;/*found*/fp = fopen(_fp_, “rb+“);/*found*/fseek(_fp_, -(long)sizeof(STU), SEEK_END);/*found*/fwrite(fclose(fp);main() STU tN= 10001,“MaChao“, 91, 92, 77, 10002,“CaoKai“, 75, 60, 88,10003,“LiSi“, 85,

10、70, 78, 10004,“FangFang“, 90, 82, 87,10005,“ZhangSan“, 95, 80, 88;STU n=10006,“ZhaoSi“, 55, 70, 68, ssN;int i,j; FILE *fp;fp = fopen(“student.dat“, “wb“);fwrite(t, sizeof(STU), N, fp);fclose(fp);fp = fopen(“student.dat“, “rb“);fread(ss, sizeof(STU), N, fp);fclose(fp);printf(“nThe original data :nn“)

11、;for (j=0; j#include typedef struct aa int data;struct aa *next; NODE;NODE *Creatlink(int n, int m) NODE *h=NULL, *p, *s;int i;/*found*/p=(NODE* )malloc(sizeof(NODE);h=p;p-next=NULL;for(i=1; idata=rand()%m; s-next=p-next;p-next=s; p=p-next;/*found*/return h;outlink(NODE *h) NODE *p;p=h-next;printf(“

12、nnTHE LIST :nn HEAD “);while(p) printf(“-%d “,p-data);p=p-next;printf(“n“);main() NODE *head;head=Creatlink(8,22);outlink(head);6、填空题15#include #define M 3#define N 4void fun(int (*a)N) int i=0,j,find=0,rmax,c,k;while( (idouble fun ( int m ) double y = 1.0 ;int i ;/*found*/for(i = 2 ; i #include int

13、 fun(int score, int m, int below)float av=0.0;int i,j=0;for(i=0;iscorei)17belowj+=scorei;return j;main( ) int i, n, below9 ;void NONO ();int score9 = 10, 20, 30, 40, 50, 60, 70, 80, 90 ;n = fun(score, 9, below) ;printf( “nBelow the average score are: “ ) ;for (i = 0 ; i #include #define N 10double f

14、un(double *x) int i, j; double av, yN;18av=0;/*found*/for(i=0; ivoid fun ( char *s, int num5 ) int k, i=5;for ( k = 0; k= 0)numi+;main( ) char s181; int num15, i;printf( “nPlease enter a string: “ ); gets( s1 );fun ( s1, num1 );for ( i=0; i #define M 4#define N 5int fun ( int aMN )int tot=0,i,j;for(

15、i=0;i#define N 5typedef struct student long sno;char name10;float score3; STU;void fun(char *filename, STU n) FILE *fp;/*found*/fp = fopen(_filename_, “rb+“);/*found*/fseek(_fp_, -(long)sizeof(STU), SEEK_END);/*found*/fwrite(fclose(fp);main() STU tN= 10001,“MaChao“, 91, 92, 77, 10002,“CaoKai“, 75, 6

16、0, 88,10003,“LiSi“, 85, 70, 78, 10004,“FangFang“, 90, 82, 87,10005,“ZhangSan“, 95, 80, 88;STU n=10006,“ZhaoSi“, 55, 70, 68, ssN;int i,j; FILE *fp;fp = fopen(“student.dat“, “wb“);fwrite(t, sizeof(STU), N, fp);fclose(fp);fp = fopen(“student.dat“, “rb“);fread(ss, sizeof(STU), N, fp);fclose(fp);printf(“

17、nThe original data :nn“);for (j=0; j#include typedef struct aa int data;struct aa *next; NODE;NODE *Creatlink(int n, int m) NODE *h=NULL, *p, *s;int i;/*found*/p=(NODE*)malloc(sizeof(NODE);h=p;p-next=NULL;for(i=1; idata=rand()%m; s-next=p-next;p-next=s; p=p-next;/*found*/return h;outlink(NODE *h) NO

18、DE *p;p=h-next;printf(“nnTHE LIST :nn HEAD “);while(p) printf(“-%d “,p-data);p=p-next;printf(“n“);main() NODE *head;head=Creatlink(8,22);outlink(head);239、填空题#include #define N 9int fun(int a, int n) int i,j;j = 0;for (i=0; i24int fun(int a,int b) int r,t;if(avoid fun( char *a )int j=0;char *p = a;w

19、hile(*p)if(*p!=*)aj+=*p;p+;aj=0;main() char s81;void NONO ( );printf(“Enter a string:n“);gets(s);25fun( s );printf(“The string after deleted:n“);puts(s);NONO();void NONO()/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */FILE *in, *out ;int i ; char s81 ;in = fopen(“K:k4924900830in.dat“,“r“) ;out = fopen(“K:k4924

20、900830out.dat“,“w“) ;for(i = 0 ; i void fun(char *s, char c) int i, j, n;/*found*/for(i=0; si!=_0_ ; i+)if(si=c)/*found*/n=_0_ ;while(si+1+n!=0) n+;for(j=i+n+1; ji; j-) sj+1=sj;/*found*/sj+1=_c_ ;i=i+1;26main() char s80=“baacda“, c;printf(“nThe string: %sn“,s);printf(“nInput a character: “); scanf(“

21、%c“,fun(s,c);printf(“nThe result is: %sn“,s);改错题#include double fun ( int x)/*found*/double sum = 0.0;int c=0, i=0;while (xi != 0) if (xi 0) sum += xi; c+; i+;/*found*/sum /= c;return sum;main( ) int x1000; int i=0;printf( “nPlease enter some data (end with 0): “ );do scanf(“%d“, while (xi+ != 0);pr

22、intf(“%fn“, fun ( x );编程题27#include double fun(int n)int i,j,t;float s=0;for(i=1;idouble f1(double x) return x*x; double f2(double x, double y) return x*y; double fun(double a, double b)/*found*/_double_ (*f)();double r1, r2;/*found*/f = _f1_ ; /* point fountion f1 */r1 = f(a);/*found*/f = _f2_ ; /*

23、 point fountion f2 */r2 = (*f)(a, b);return r1 + r2;main() double x1=5, x2=3, r;r = fun(x1, x2);printf(“nx1=%f, x2=%f, x1*x1+x1*x2=%fn“,x1, x2, r);改错题29#include #include typedef struct aa int data; struct aa *next; NODE;int fun(NODE *h) int sum = 0 ;NODE *p;/*found*/p=h-next;while(p) if(p-data%2=0)s

24、um +=p-data;/*found*/p=p-next;return sum;NODE *creatlink(int n) NODE *h, *p, *s;int i;h=p=(NODE *)malloc(sizeof(NODE);for(i=1; idata=rand()%16;s-next=p-next;p-next=s;p=p-next;p-next=NULL;return h;outlink(NODE *h, FILE *pf) NODE *p;p = h-next;fprintf(pf ,“nnTHE LIST :nn HEAD “ );while(p) fprintf(pf ,

25、“-%d “,p-data ); p=p-next; fprintf (pf,“n“);30outresult(int s, FILE *pf) fprintf(pf,“nThe sum of even numbers : %dn“,s);main() NODE *head; int even;head=creatlink(12);head-data=9000;outlink(head , stdout);even=fun(head);printf(“nThe result :n“); outresult(even, stdout);编程题#include #include #define N 80int fun(char *str)int i,j=strlen(str);for(i=0;ij/2;i+)if(stri!=strj-i-1)return 0;return 1;main() char sN ;void NONO ();printf(“Enter a string: “) ; gets(s) ;printf(“nn“) ; puts(s) ;if(fun(s) printf(“ YESn“) ;else printf(“ NOn“) ;NONO() ;void NONO ()/* 请在此函数内打开文件,输入测试数据,调用 fun 函数,输出数据,关闭文件。 */

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报