全国计算机C语言二级上机试题10套3140.docx
- 文档编号:568298
- 上传时间:2022-10-11
- 格式:DOCX
- 页数:30
- 大小:20.62KB
全国计算机C语言二级上机试题10套3140.docx
《全国计算机C语言二级上机试题10套3140.docx》由会员分享,可在线阅读,更多相关《全国计算机C语言二级上机试题10套3140.docx(30页珍藏版)》请在冰豆网上搜索。
全国计算机C语言二级上机试题10套3140
31
#include
#include
#defineN8
typedefstructlist
{intdata;
structlist*next;
}SLIST;
SLIST*creatlist(int*a);
voidoutlist(SLIST*);
voidfun(SLIST*h,int*n)
{SLIST*p;
/**********found**********/
___1___=0;
p=h->next;
while(p)
{(*n)++;
/**********found**********/
p=p->___2___;
}
}
main()
{SLIST*head;
inta[N]={12,87,45,32,91,16,20,48},num;
head=creatlist(a);outlist(head);
/**********found**********/
fun(___3___,&num);
printf("\nnumber=%d\n",num);
}
SLIST*creatlist(inta[])
{SLIST*h,*p,*q;inti;
h=p=(SLIST*)malloc(sizeof(SLIST));
for(i=0;i {q=(SLIST*)malloc(sizeof(SLIST)); q->data=a[i];p->next=q;p=q; } p->next=0; returnh; } voidoutlist(SLIST*h) {SLIST*p; p=h->next; if(p==NULL)printf("ThelistisNULL! \n"); else {printf("\nHead"); do {printf("->%d",p->data);p=p->next;} while(p! =NULL); printf("->End\n"); } } 00000000000000 #include #include char*fun(char*s,char*t) { char*p,*r,*a; /************found************/ a=Null; while(*s) {p=s;r=t; while(*r) /************found************/ if(r==p) {r++;p++;} elsebreak; if(*r=='\0')a=s; s++; } returna; } main() { chars[100],t[100],*p; printf("\nPleaseenterstringS: ");scanf("%s",s); printf("\nPleaseentersubstringt: ");scanf("%s",t); p=fun(s,t); if(p)printf("\nTheresultis: %s\n",p); elseprintf("\nNotfound! \n"); } 00000000000000000000000000000 #include #include voidfun(char*s,chart[]) { } NONO() {/*本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */ chars[100],t[100]; FILE*rf,*wf; inti; rf=fopen("C: \\WEXAM\\YS240001\\in.dat","r"); wf=fopen("C: \\WEXAM\\YS240001\\out.dat","w"); for(i=0;i<10;i++){ fscanf(rf,"%s",s); fun(s,t); fprintf(wf,"%s\n",t); } fclose(rf); fclose(wf); } main() { chars[100],t[100]; printf("\nPleaseenterstringS: ");scanf("%s",s); fun(s,t); printf("\nTheresultis: %s\n",t); NONO(); } 32 #include doublefun(doublee) {inti;doubles,x; /**********found**********/ s=0;i=__1__; x=1.0; while(x>e){ /**********found**********/ __2__; /**********found**********/ x=(2.0*i-1)/((__3__)*(2.0*i)); s=s+x; } returns; } main() {doublee=1e-3; printf("\nTheresultis: %f\n",fun(e)); } 00000000000000000000 #include #include /************found************/ voidfun(chars,chart) { inti,d; d=strlen(s); for(i=0;i for(i=0;i /************found************/ t[2*d-1]='\0'; } main() { chars[100],t[100]; printf("\nPleaseenterstringS: ");scanf("%s",s); fun(s,t); printf("\nTheresultis: %s\n",t); } 00000000000000000000000 #include #include voidfun(char*s,chart[]) { } NONO() {/*本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */ chars[100],t[100]; FILE*rf,*wf; inti; rf=fopen("C: \\WEXAM\\YS240001\\in.dat","r"); wf=fopen("C: \\WEXAM\\YS240001\\out.dat","w"); for(i=0;i<10;i++){ fscanf(rf,"%s",s); fun(s,t); fprintf(wf,"%s\n",t); } fclose(rf); fclose(wf); } main() { chars[100],t[100]; printf("\nPleaseenterstringS: ");scanf("%s",s); fun(s,t); printf("\nTheresultis: %s\n",t); NONO(); } 33 #include #defineN9 intfun(inta[],intn) {inti,j; j=0; for(i=0;i /**********found**********/ if(___1___==0){ /**********found**********/ ___2___=a[i];j++; } /**********found**********/ return___3___; } main() {intb[N]={9,1,4,2,3,6,5,8,7},i,n; printf("\nTheoriginaldata: \n"); for(i=0;i printf("\n"); n=fun(b,N); printf("\nThenumberofeven: %d\n",n); printf("\nTheeven: \n"); for(i=0;i printf("\n"); } 0000000000000000000000 #include /************found************/ fun(n) {intc; /************found************/ if(n=1) c=10; else c=fun(n-1)+2; return(c); } main() {intn; printf("Entern: ");scanf("%d",&n); printf("Theresult: %d\n\n",fun(n)); } 0000000000000000000000000 #include voidfun(char*a,intn) { } NONO() {/*本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */ FILE*in,*out; inti,n;chars[81]; in=fopen("C: \\WEXAM\\YS240001\\in.dat","r"); out=fopen("C: \\WEXAM\\YS240001\\out.dat","w"); for(i=0;i<10;i++){ fscanf(in,"%s",s); fscanf(in,"%d",&n); fun(s,n); fprintf(out,"%s\n",s); } fclose(in); fclose(out); } main() {chars[81];intn; printf("Enterastring: \n");gets(s); printf("Entern: ");scanf("%d",&n); fun(s,n); printf("Thestringafterdeleted: \n");puts(s); NONO(); }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 全国计算机 语言 二级 上机 试题 10 3140