计算机二级c语言编程100题.docx
- 文档编号:10806801
- 上传时间:2023-02-23
- 格式:DOCX
- 页数:111
- 大小:1.57MB
计算机二级c语言编程100题.docx
《计算机二级c语言编程100题.docx》由会员分享,可在线阅读,更多相关《计算机二级c语言编程100题.docx(111页珍藏版)》请在冰豆网上搜索。
计算机二级c语言编程100题
#include
#include
voidfun(char*a,char*h,char*p)
{charb[81],*x;
inti=0,j=0;
x=a;
while(x while(h<=p) if(*h! ='*'){b[j]=*h;j++;h++;} elseh++; p++; while(*p){b[j]=*p;j++;p++;} b[j]='\0';j=0; while(b[j]) {a[i]=b[j];i++;j++;} a[i]='\0'; } main() {chars[81],*t,*f; printf("Enterastring: \n");gets(s); t=f=s; while(*t)t++; t--; while(*t=='*')t--; while(*f=='*')f++; fun(s,f,t); printf("Thestringafterdeleted: \n");puts(s); NONO(); } 2 #include #include doublefun(doubleeps) { intn=0; doubledown=1,up=1; doubleone,pi=0; one=(double)up/(double)down; while(one>=eps){ pi+=one; n++; up=up*n; down=down*(2*n+1); one=(double)up/(double)down; } returnpi*2; } main() {doublex; printf("Inputeps: "); scanf("%lf",&x);printf("\neps=%lf,PI=%lf\n",x,fun(x)); NONO(); } 3 #include char*fun(char*s,char*t) { intfirst=0,second=0; char*p,*q; p=s; q=t; while(*p++! ='\0') first++; while(*q++! ='\0') second++; if(first==second) returns; elseif(first>second) returns; else returnt; } main() {chara[20],b[10]; printf("Input1thstring: "); gets(a); printf("Input2thstring: "); gets(b); printf("%s\n",fun(a,b)); NONO(); } 4 #include #include voidfun(char*a,intn) {charb[81]; inti=0,j=0,s=0,k; while(a[i]=='*'){s++;i++;} if(s>n) {for(k=0;k {b[j]='*';j++;} while(a[i]) {b[j]=a[i];j++;i++;} b[j]='\0';i=0;j=0; while(b[j]) {a[i]=b[j];i++;j++;} a[i]='\0'; } } main() {chars[81];intn; printf("Enterastring: \n");gets(s); printf("Entern: ");scanf("%d",&n); fun(s,n); printf("Thestringafterdeleted: \n");puts(s); NONO(); } 5 #include floatfun(float*a,intn) { inti; floataverage; doublesum=0; for(i=0;i sum+=a[i]; average=(float)sum/n; returnaverage; } main() {floatscore[30]={90.5,72,80,61.5,55},aver; aver=fun(score,5); printf("\nAveragescoreis: %5.2f\n",aver); NONO(); } 6 #include #defineN8 typedefstruct {charnum[10]; doubles[N]; doubleave; }STREC; voidfun(STREC*p) {inti; doubleaver=0; for(i=0;i {aver=aver+(*p).s[i];} (*p).ave=aver/N; } main() {STRECs={"GA005",85.5,76,69.5,85,91,72,64.5,87.5}; inti; fun(&s); printf("The%s'sstudentdata: \n",s.num); for(i=0;i printf("%4.1f\n",s.s[i]); printf("\nave=%7.3f\n",s.ave); NONO(); } 7 #include #defineN12 typedefstruct {charnum[10]; doubles; }STREC; doublefun(STREC*a,STREC*b,int*n) {inti,j; doubleaver=0; *n=0; for(i=0;i aver=aver+a[i].s; aver=aver/N; for(i=0;i if(a[i].s>=aver) {b[*n].s=a[i].s; for(j=0;j<10;j++) b[*n].num[j]=a[i].num[j]; *n=*n+1; } return(aver); } main() {STRECs[N]={{"GA05",85},{"GA03",76},{"GA02",69},{"GA04",85},{"GA01",91},{"GA07",72},{"GA08",64},{"GA06",87},{"GA09",60},{"GA11",79},{"GA12",73},{"GA10",90}}; STRECh[N];FILE*out; inti,n;doubleave; ave=fun(s,h,&n); printf("The%dstudentdatawhichishigherthan%7.3f: \n",n,ave);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 二级 语言 编程 100