福建省计算机二级C语言上机题解析_第1页
福建省计算机二级C语言上机题解析_第2页
福建省计算机二级C语言上机题解析_第3页
福建省计算机二级C语言上机题解析_第4页
福建省计算机二级C语言上机题解析_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

精心整理精心整理精心整理精心整理第一部分:程序修改题#include<math.h>#include<stdio.h>#include<string.h>#include<conio.h>voidmain(){charstr1[100],t[200];inti,j;/**/i=0;/**/ 改成j=0;clrscr();strcpy(str1,"4AZ18c?Ge9a0z!");for(i=0;i<strlen(str1);i++)/**/if((str1[i]%2==0)&&(i%2!=0))/**/改成 i%2==0t[j]=str1[i];j++;t[j]='\0';printf("\nOriginalstring:%s\n”,str1);printf("\nResultstring:%s\n",t);#include<string.h>#include<conio.h>#include<math.h>#include<stdio.h>#defineM50doublefun(intn){doubley=0.0;inti,j;j=0;for(i=1;;i++)/**/if((i<10)&&(i%3==0))/**/ 改成i>10{/**/y+=1/i;/**/ 改成y+=1.0/i;j++;}if(j==n)break;}returny;}voidmain(){clrscr();printf("fun(8)=%8.3lf\n",fun(8));}#include<stdio.h>voidmain(){/**/inti,j;/**/ 改成inti,j,k;for(i=1;i<=6;i++){for(k=1;k<=10+i;k++)printf("");for(j=1;j<=7-i;j++)printf("*")/**/:/**/改成;printf("\n");}getch();}#include<stdio.h>#include<conio.h>/**/intfun();/**/ □□□□□□□□,□□□□□□{inthen,cock,chicken,n=0;clrscr();for(cock=0;cock<=50;cock+=1)for(hen=0;hen<=100;hen=hen+1){chicken=2*(100-hen-2*cock);/**/if(cock+hen+chicken=100)/**/□□□□□□□{n++;printf("%d-->hen:%d,cock:%d,chicken:%d\n”,n,hen,cock,chicken);if(n==20)getch();}}returnn;}voidmain(){intnum;num=fun();printf("\nThereare%dsolutions.\n",num);getch();}#include<stdio.h>#include<conio.h>voidmain(){intm,n,result,flag=0;/**/charch,/**/□□□□□□,□□□□□□clrscr();printf("Inputanexpression:");scanf("%d%c%d",&m,&ch,&n);/**/switchch/**/基本格式错误,改成 switch(ch){case'+':result=m+n;break;case'-':result=m-n;break;case'*':result=m*n;break;case'%':result=m%n;break;case'/':result=m/n;break;default:{printf("Error!\n");flag=1;}}if(!flag)printf("%d%c%d=%d\n",m,ch,n,result);getch();}#include<stdio.h>#include<string.h>voidmain(){chars[20]="tableleft100",t[20];/**/chartab[4,2]={{'a','f'},{'b','e'},{'e','a'},{R'b'}};/**/□□□□□□□□,□□ chartab[4][2]inti,j=0;strcpy(t,s);while(t[j]){for(i=0;i<=3;i++){if(t[j]==tab[i][0]){/**/t[j]=tab[i][2];/**/改成t[j]=tab[i][1];break;}}j++;}printf("\nThesourcestring:%s\n",s);printf("\nThetargetstring:%s\n",t);getch();}#include<stdio.h>#include<string.h>main(){charstr1[128];/**/inti,len;sum=0;/**/基本语法错误,改成 inti,len,sum=0;printf("\nPleaseinputthestring:");gets(str1);len=strlen(str1);for(i=0;i<len;i++){/**/if(str1[i]>='0'||str1[i]<='9')/**/逻辑错误, ||改成&&sum++;}printf("%d\n",sum);getch();}#include<stdio.h>#include<math.h>#defineM8main(){inta[M],i;printf("Pleaseinput8numbers:\n");for(i=0;i<M;i++)scanf("%d",/**/a[i]/**/);输入列表项必须指定地址,改成 &a[i]printf("Inverseorderis:\n");/**/for(i=M-1;i<=0;i--)/**/循环判断条件表示错误,改成 i>=0printf("%d",a[i]);printf("\n");getch();}#include<stdio.h>#include<string.h>main(){/**/charstr1/**/;□□□□□□□□□□□,□□ charstr1[50]inti,len,sum=0;printf("Pleaseinputastring:\n");scanf("%s",str1);len=strlen(str1);for(i=0;i<len;i++){if(str1[i]>='A'&&str1[i]<='Z')/**/sum--;/**/改成 sum++;}printf("%d\n",sum);getch();}#include<stdio.h>#include<math.h>/**/#includeM5/**/宏定义错误,改成 #defineM5main(){inta[M],i;printf("Pleaseinput5numbers:\n");for(i=0;i<M;i++)scanf("%d",&a[i]);printf("Evennumbers:\n");for(i=0;i<M;i++)a[i]%2==0/**/if(a[i]/2==0)/**/判断偶数应该改成a[i]%2==0printf("%d",a[i]);printf("\n");getch();}#include<stdio.h>#include<string.h>main(){charstr1[128],str2[128];inti,len;gets(strl);len=strlen(str1);/**/for(i=0;i>len;i++)/**/循环条件表示错误,改成 for(i=0;i<len;i++){if(str1[i]>='0'&&str1[i]<='8')str2[i]=str1[i]+1;elseif(str1[i]=='9')str2[i]='0';elsestr2[i]=str1[i];}/**/str2[i]='\n';/**/字符串的结束标识应该用 '\0'表示puts(str2);getch();}l #include<stdio.h>#include<string.h>voidmain(){chars1[30]="People'sRepublicof",s2[]="China";char*ps1,*ps2;/**/ps1=NULL;/**/指针 psi□□□□□si,改成ps1=s1;ps2=s2;/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成 *ps1!='\0'ps1++;while(*ps2)*(ps1++)=*(ps2++);printf("\n%s\n",s1);精心整理精心整理精心整理getch();}#include<stdio.h>#include<math.h>voidmain(){floata[3],s,area;inti;printf("Pleaseinput3numbers:\n");for(i=0;i<3;i++)scanf("%f",/**/a[i]/**/);输入列表项必须指定地址/**/if(a[0]+a[1]>a[2]11a[1]+a[2]>a[0]11a[0]+a[2]>a[1])/**/□□□□□□□□, ||改成&&{s=(a[0]+a[1]+a[2])/2;area=sqrt(s*(s-a[0])*(s-a[1])*(s-a[2]));printf("areais%.2f\n",area);}elseprintf("error.\n");getch();}#include<stdio.h>#include<conio.h>/**/voidfun()/**/此处说明函数有返回值,改成 intfun(){intlarge,middle,small,n=0;clrscr();for(large=0;large<=33;large++)for(middle=0;middle<=50;middle++){small=2*(100-3*large-2*middle);/**/if(large+mi,dle+small=100)/**/=改成=={n++;printf("%d-->large:%d,middle:%d,small:%d\n”,n,large,middle,small);}treturnn;}voidmain(){intnum;num=fun();)printf("\nThereare%dsolutions.\n",num);getch();}#include<stdio.h>voidmain(){inti;/**/for(i=100;i<200;i++);/**/for语句错误,此处去掉分号if((i-2)%4==0)if(!((i-3)%7))if(i%9==5)printf("%d\n",/**/&i/**/);去掉地址符号 &getch();}#include<stdio.h>/**/voidswap(intp1,intp2)/**/改成 voidswap(int*p1,int*p2){inttemp;temp=*p1;/**/p1=p2;/**/改成*p1=*p2;*p2=temp;}voidmain(){inta,b;printf("pleaseinput2numbers:\n");scanf("%d%d”,&a,&b);printf("\nOriginal:a=%db=%d\n",a,b);swap(&a,&b);printf("\nResult:a=%db=%d\n",a,b);getch();}#include<stdio.h>voidmain(){intb,i;/**/inta=c=0;/**/基本语法错误,改成 inta=0,c=0;/**/for(i=0,i<=100,i+=2)/**/for□□□□□□,□□ for(i=0;i<=100;i+=2){a+=i;b=i+1;c+=b;}printf("totalofevennumbers:%d\n",a);printf("totalofoddnumbers:%d\n",c-101);getch();}#include<stdio.h>voidmain(){intx,y,z,i,result=520;for(x=1;x<10;x++)for(y=1;y<10;y++)/**/for(z=1;z<10;z++)/**/z初值应为 0,改成 for(z=0;z<10;z++){i=100*x+10*y+z+100*y+10*z+z;/**/if(i=result)/**/逻辑关系等于应该为 i==resultprintf("x=%d,y=%d,z=%d\n",x,y,z);}getch();}#include<stdio.h>#defineF(x)(x*x-2.3*x+5.6)/(x+8.2)voidmain(){floata=6.0,b=3.0,c;/**/ints;/**/变量类型错误,改成 floats;printf("\nPleaseinputc:");scanf("%f",/**/c/**/);输入列表项必须加地址 &c/**/s=F(a,b,c);/**/printf("\ns=%.2f\n",s);getch();}#include<stdio.h>voidmain(){intf,s,t,n;printf("\nThelistis:\n");for(n=100;n<1000;n++){f=n%10; f为个位数s二(n%100)/10;s为十位数/**/t=n%100;/**/ t□□□□,□□□ t=n/100;/**/if(t*t*t+s*s*s+f*f*f=n)/**/ □□□□□□printf("%d",n);}printf("\n");getch();}第二部分:程序填空题#include<stdio.h>voidmain(){/**/long/**/p;精心整理精心整理p=1;/**/for/**/(i=1;i<=8;i++)P=P*i;printf("\np=%ld",p);getch();}#include<stdio.h>voidmain(){inta,b,c;floatf;clrscr();printf("Pleaseinputab:");scanf("%d%d”,&a,&b);f=/**/1.0*a/b/**/;c=/**/(int)/**/(f*100)%10;printf("\na/b=%fTheseconddecimalplaceis:%d\n",f,c);getch();}#include<stdio.h>#include<stdlib.h>intmax,min;voidfind_max_min(int*p,intn){——int*q;max=min=*p;for(q=p;q</**/p+n/**/;q++)if(/**/max<*q/**/)max=*q;elseif(min>*q)min=*q;}voidmain(){inti,num[10];printf("Input10numbers:");for(i=0;i<10;i++)scanf("%d",&num[i]);find_max_min(/**/num/**/,10);printf("max=%d,num=%d\n",max,min);}#include<stdio.h>voidmain(){inta,b,k;intplu=/**/403/**/;for(a=1;a<10;a++)for(b=1;b<10;b++){k=(a*10+b)*/**/(b*10+a)/**/;if(k==plu)printf("A=%d,B=%d\n",a,b);}}#include<stdio.h>voidmain(){intn,a,b;/**/a=0;b=0;/**/scanf("%d",&n);while(/**/n!=0/**/){if(n>0)a++;else/**/b++;/**/scanf("%d",&n);}printf("Positiveinteger:%d,negativeinteger:%d\n",a,b);}#include<stdio.h>#include<conio.h>intprime(intn){intk,flag=1;for(k=2;k<=n/2+1;k++)if(n%k==0){flag=/**/0/**/;break;}returnflag;}voidmain(){intnum,a;clrscr();do{printf("Pleaseinputanevennumber:");scanf("%d",&num);}while(num<=6||num%2==1);for(a=2;a<=num/2+1;a++)if(prime(a)&&prime(/**/num-a/**/))printf("\n%d=%d+%d",num,a,num-a);}#include<stdio.h>#include<math.h>/**/main()/**/{floatx,x0,f,f1;x=1.5;do{x0=x;f=((2*x0-4)*x0+3)*x0-6;f1=(6*x0-8)*x0+3;x=x0-f/f1;}/**/while/**/(fabs(x-x0)>=1e-6);printf("therootis:%.2f\n",x);}#include<stdio.h>main(){/**/char/**/str[20];inti;floatx;printf("Pleaseinputastring:\n");scanf("%s",/**/str/**/);』0;while(str[i])str[i]=/**/str[i]A15;/**/i++;printf("\nTargetstring:%s\n",str);getch();#include<stdio.h>main()inta[5]={20,30,45,64,23};floatm;/**/floataverage(intpa[],intn);/**/m=average(a,5);printf("Average=%f\n",m);getch();floataverage(intpa[],intn){intk;floatavg=0.0;for(k=0;k<n;k++)avg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#include<stdio.h>main(){/**/char/**/s[80];精心整理inti;printf("Pleaseinputastring:");for(i=0;(s[i]=getchar())!='\n';i++);s[i]='\0';for(i=0;s[i]!='\0';i++){if(s[i]>='a'&&s[i]<='z')s[i]=s[i]-32;/**/elseif/**/(s[i]>='A'&&s[i]<='Z')s[i]=s[i]+32;printf("%c",s[i]);}getch();#include<stdio.h>#include<math.h>voidsort(inta[],intm){inti,j,t,swap;for(i=0;i</**/m-1/**/;i++)swap=0;for(j=0;j<m-i-1;j++)if/**/(a[j]<a[j+1])/**/swap=1;t=a[j];a[j]=/**/a[j+1]/**/;a[j+1]=t;if(!swap)break;voidmain()inta[]={23,55,8,32,18,2,9};inti,k=sizeof(a)/sizeof(int);sort(a,k);for(i=0;i<k;i++)printf("%d",a[i]);printf("\n");getch();}#include<stdio.h>#include<math.h>intfun(/**/floata,floatb,floatc/**/)精心整理{floattemp;intbTrue=0;if(a<b){temp=a;a=b;b=temp;}if(a<c){temp=a;a=c;c=temp;if(fabs(/**/a*a/**/-(b*b+c*c))<1.0e-15)bTrue=1;returnbTrue;main()floata,b,c;printf("Pleaseinputthreenumbers:\n");scanf("%f%f%f",&a,&b,&c);if(fun(a,b,c)==1)printf("Yes'n");elseprintf("No\n");getch();#include<stdio.h>main(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();#include<stdio.h>#include<math.h>voidsort(inta[],intm){inti,j,k,t;for(i=0;i<m-1;i++){k=i;for(j=i+1;j</**/m/**/;j++)if(a[j]<a[k])/**/k=j/**/;if(k!=i){t=a[k];精心整理精心整理精心整理a[k]=a[i];a[i]=/**/t/**/;}}}voidmain(){inta[]={72,25,58,32,2,15,7,64};inti,m=sizeof(a)/sizeof(int);sort(a,m);for(i=0;i<m;i++)printf("%d",a[i]);printf("\n");getch();}#include<stdio.h>main(){floata,b,c,max;/**/floatfmax(floatx,floaty,floatz);/**/printf("Pleaseinput3integer:\n");scanf("%f%f%f",&a,&b,&c);max=fmax(a,b,c);printf("Themaxnumberis:%.2f\n",max);getch();}floatfmax(floatx,floaty,floatz){floatm,n;n=(y>z)?y:z;m=/**/(x>n)?x:n;/**/return(m);}#include<stdio.h>#include<math.h>main(){inti,/**/j/**/;inta[4][4],sum;sum=/**/0/**/;printf("Pleaseinput16numbers:\n");for(i=0;i<4;i++)for(j=0;j<4;j++)scanf("%d",&a[i][j]);for(i=0;i<4;i++)/**/sum+=a[i][0];/**/printf("%d\n",sum);getch();#include<stdio.h>intfun(inta[],intn,/**/intq/**/){intleft,right,mid;left=0;right=n-1;while(left<=right){mid=/**/(left+right)/2/**/;if(q<a[mid])right=mid-1;elseif(q>a[mid])left=mid+1;elsereturnmid;return-1;main(){inta[卜{3,4,6,11,17,22,31,45};intk,n;n=sizeof(a)/sizeof(int);k=fun(a,n,31);printf("%d\n",k);getch();#include<stdio.h>#include<math.h>intfun(/**/floatr/**/,floatx,floaty)intbIn;bIn=/**/sqrt(x*x+y*y)/**/<r;returnbIn;main(){floatr=-1,x,y;intbIn;while(r<0){printf("Pleaseinputradiusr(r>0):\n");scanf("%f",&r);}printf("Pleaseinputthedot(x,y):\n");scanf("%f%f",&x,&y);bIn=fun(r,x,y);精心整理if(bIn==1)printf("inthecircle!\n");elseprintf("outoftheCircle!\n");getch();}#include<stdio.h>/**/#include<math.h>/**/doublefun(doublex){/**/returnx*x-2*x+6;/**/voidmain()doublex,y1,y2;clrscr();printf("Pleaseinputx:");scanf("%lf",&x);y1=fun(x+8);y2=fun(/**/sin(x)/**/);printf("\nf(x+8)=%.3lf",y1);printf("\nf(sinx)=%.3lf",y2);getch();#include<stdio.h>doublefun(unsignedm,unsignedn)unsignedi;doublep=1.0;for(i=1;i<=m;i++)/**/p=p*i;/**/for(i=1;i<=n;i++)/**/p=p/i;/**/for(i=1;i<=m-n;i++)p=p/i;returnp;}voidmain(){clrscr();printf("p=%f\n",fun(13,7));getch();}#include<stdio.h>intfindmax(int*array,intsize);voidmain()精心整理精心整理精心整理{inta[]={33,91,23,45,56,-12,32,12,5,90};clrscr();printf("Themaxis%d\n",/**/findmax(a,10)/**/);getch();}intfindmax(int*array,intsize){inti,/**/max=*array/**/;for(i=1;i<size;i++)if(array[i]>max)max=array[i];returnmax;}#include<stdio.h>unsignedsum(unsignedn){unsignedi,/**/sum=0;/**/for(i=1;i<=n;i++)sum+=i;/**/returnsum;/**/}voidmain(){intm;clrscr();printf("Pleaseinputaunsignedinteger:");scanf("%d",&m);while(m<0){printf("Pleaseinputaunsignedinteger:");scanf("%d",&m);}printf("\nThesumis%d\n",/**/sum(m)/**/);getch();}#include<stdio.h>#include<string.h>voidmain(){inti,j;charstr[]="1234567",/**/k/**/;for(i=0,/**/j=strlen(str)-1/**/;i<j;i++,j--){k=str[i];str[i]=str[j];str[j]=k;}clrscr();printf("%s\n",str);getch();}#include<stdio.h>#include<string.h>typedefstruct{intnum;charname[20],sex[2];intage,score;}STU;STUmystudent口={{1111,"Zhangqiang","m",20,80},{2104,"Liminghong","w",18,82},{3121,"Wangxingda","m",21,78},{4118,"Liushaotao","m",20,90},{1456,"Wuminghong","w",35,86}};voidsort(STU*ps,intsize){inti,flag,pass;/**/STUtemp;/**/for(pass=1;pass<size;pass++){flag=0;for(i=0;i<size-pass;i++)if(/**/ps[i].num>ps[i+1].num/**/){flag+=1;temp=ps[i];ps[i]=ps[i+1];ps[i+1]=temp;}if(/**/flag>size/**/)break;}}voidmain(){inti,size=sizeof(mystudent)/sizeof(STU);clrscr();printf("Students\'informationbeforesort:\n\n");printf("NumberNameageSexscore\n\n");for(i=0;i<size;i++)printf("%-7d%s%10d\t%s%8d\n",(mystudent+i)->num,(mystudent+i)->name,(mystudent+i)->age,(mystudent+i)->sex,(mystudent+i)->score);sort(mystudent,size);printf("\nStudents\'informationaftersort:\n\n");printf("NumberNameageSexscore\n\n");for(i=0;i<size;i++)printf("%-7d%s%5d\t%s%7d\n",(mystudent+i)->num,(mystudent+i)->name,(mystudent+i)->age,(mystudent+i)->sex,(mystudent+i)->score);getch();}#include"stdio.h"#defineROW3#defineCOL3voidmain(){inta[ROW][COL],i,j,max,min;clrscr();printf("Pleaseinputthe9integers:\n");for(i=0;i<ROW;i++)for(j=0;j<COL;j++)scanf("%d",&a[i][j]);/**/max=min=a[0][0];/**/for(i=0;i<ROW;i++)for(j=0;j<COL;j++){if(/**/a[i][j]>max/**/)max=a[i][j];if(a[i][j]<min)/**/min=a[i][j];/**/}printf("max=%d\n",max);printf("min=%d\n",min);getch();}#defineN5#include<stdio.h>voidmain(){intt=0,/**/s=0/**/,i;for(i=1;i<=N;i++){t=/**/t*10+i/**/;s+=t;}clrscr();printf("\ns=%d\n",s);getch();}#include<stdio.h>longfib(intn);voidmain(){intk;clrscr();printf("Thefirst15dataofFibonacciis:\n\n");for(k=1;k<=15;k++)printf("%d",fib(k));printf("\n");getch();}longfib(intn)if(n==1||n==2)/**/return1;/**/elsereturn/**/fib(n-1)+fib(n-2)/**/;#include<stdio.h>main()structstucharname[10];floatscore;/**/structstu/**/stu[3]={"Mary",76,"John",85,"Tom",81};inti=0;floattotal=0,aver=0;while(i<3)total=total+/**/stu[i].score/**/;i++;aver=total/3;printf("\ntotal=%.2f,aver=%.2f”,total,aver);getch();}#include<stdio.h>main(){inti,a[10]={9,26,35,8,6,19,69,3,5,95};intmin1,min2;i=0;min1=a[0]<a[1]?a[0]:a[1];min2=a[0]>a[1]?/**/a[0]:a[1];/**/精心整理for(i=2;i<10;i++){if(a[i]<min1){min2=min1;min1=a[i];}elseif(a[i]<min2)/**/min2=a[i];/**/}printf("min1=%d,min2=%d\n",min1,min2);getch();#include<math.h>main()doublex,y;/**/doublemysqrt(doublea,doublex0);/**/printf("Pleaseinputx:\n");scanf("%lf",&x);y=mysqrt(x,1.0);printf("Thesqrtof%f=%f\n",x,y);getch();doublemysqrt(doublea,doublex0)doublex1,y;x1=/**/1.0/2*(x0+a/x0);/**/if(fabs(x1-x0)>0.00001)y=mysqrt(/**/a,x1/**/);elsey=x1;return(y);□□□□:□□□□□#include<math.h>#include<stdio.h>doublefun1(doublex){/**/return(1+sin(x)+exp(x))/(1+x);/**/}voidmain(){clrscr();printf("fun1(0.76)=%8.3lf\n",fun1(0.76));精心整理精心整理精心整理printf("fun1(3.00)=%8.3lf\n",fun1(3.00));printf("fun1(3.76)=%8.3lf\n",fun1(3.76));}#include<string.h>#include<conio.h>#include<math.h>#include<stdio.h>intfun2(inta[],intn,intb[],intc[]){/**/inti,j,t,k=0;for(i=0;i<n;i++)if(a[i]>-20)b[k++]=a[i];for(i=0;i<k;i++)c[i]=b[i];for(i=0;i<k;i++)for(j=0;j<k-i;j++)if(c[j]>c[j+1]){t=c[j];c[j]=c[j+1];c[j+1]=t;}returnk;/**/}voidmain(){intn=10,i,nb;intaa[10]={12,-10,-31,-18,-15,50,17,15,-20,20};intbb[10],cc[10];clrscr();printf("Thereare%2delementsinaa.\n",n);printf("Theyare:");for(i=0;i<n;i++)printf("%6d",aa[i]);printf("\n");nb=fun2(aa,n,bb,cc);printf("Elementsinbbare:");for(i=0;i<nb;i++)printf("%6d",bb[i]);printf("\n");printf("Elementsinccare:");for(i=0;i<nb;i++)printf("%6d",cc[i]);printf("\n");printf("Thereare%2delementsinbb.\n",nb);}#include<math.h>#include<stdio.h>doublefun1(doublex){/**/return(exp(x)+fabs(x-6))/(x+1.3);/**/}voidmain(){clrscr();printf("fun1(0.76)=%8.3lf\n",fun1(0.76));printf("fun1(3.00)=%8.3lf\n",fun1(3.00));printf("fun1(3.76)=%8.3lf\n",fun1(3.76));}#include<string.h>#include<conio.h>#include<math.h>#include<stdio.h>voidfun2(chara[],charb[],charc[]){/**/chart[15];if(strcmp(a,b)>0){strcpy(t,a);strcpy(a,b);strcpy(b,t);}if(strcmp(a,c)>0){strcpy(t,a);strcpy(a,c);strcpy(c,t);}if(strcmp(b,c)>0){strcpy(t,b);strcpy(b,c);strcpy(c,t);}/**/}voidmain(){charstr1[15]="Fuzhou",str2[15]="Fujian",str3[15]="China";clrscr();fun2(str1,str2,str3);printf("Theorderedstringsis:%s,%s,%s\n”,str1,str2,str3);getch();}#include<stdio.h>#include<math.h>doublefunl(floatx){/**/if(x<5)returnexp(x)+0.9;elseif(x==5)return12.5;elsereturn(sin(x)-7.8)/(2*x);/**/}voidmain(){floatx;doubley;clrscr();printf("Pleaseinputanumber:\n");scanf("%f",&x);y=fun1(x);printf("fun1(%.2f)=%.2f\n",x,y);getch();}#include<stdio.h>#include<math.h>voidmain(){intfun();intnum;num=fun();printf("\nThetotalofprimeis%d",num);getch();intfun()/**/intm,i,k,n=0;for(m=101;m<=200;m=m+2)k=sqrt(m);for(i=2;i<=k;i++)if(m%i==0)break;if(i>=k+1)n++;returnn;/**/#include<stdio.h>#include<math.h>doublef(floatx)/**/if(x>0)return(fabs(x)+3.2)/(sin(x)+2);elsereturn0;/**/}voidmain(){floatx;doubley;printf("Pleaseinputanumber:\n");scanf("%f",&x);y=f(x);printf("f(%.3f)=%.3f\n",x,y);getch();}#include<stdio.h>#include<math.h>voidfun(inta[],intm){/**/inti;a[0]=a[1]=1;for(i=2;i<m;i++)a[i]=a[i-1]+a[i-2];/**/voidmain()inta[20],i;fun(a,20);for(i=0;i<20;i++)printf("%d",a[i]);printf("\n");getch();#include<stdio.h>#include<math.h>doublef(floatx)/**/if(fabs(x)<700)returnsqrt(5.8+fabs(x))/(cos(x)+2.1);elsereturn-1;/**/voidmain()floatx;doubley;printf("Pleaseinputanumber:\n");scanf("%f",&x);y=f(x);printf("f(%0.2f)=%0.2f\n",x,y);getch();}#include<stdio.h>#include<math.h>intfun(inta[][3],intm){精心整理/**/inti,j,flag=1;for(i=0;i<m;i++)for(j=0;j<m;j++)if(a[i][j]!=a[j][i]){flag=0;break;}if(flag)return1;elsereturn0;/**/}voidmain(){nta[3][3],i,j;intb;for(i=0;i<3;i++)for(j=0;j<3;j++)scanf("%d",&a[i][j]);b=fun(a,3);if(b==1)printf("Yes'n");elseprintf("No\n");getch();#include<stdio.h>#include<math.h>doublef(floatx)/**/doubley;if(x<2)y=x;elseif(x<5)y=3-tan(3.5-x);elsey=3*log10(x)-11;returny;/**/voidmain(){floatx;doubley;clrscr();printf("Pleaseinputx:\n");scanf("%f",&x);y=f(x);printf("f(%.2f)=%.2f\n",x,y);getch();精心整理}#include<stdio.h>#include<math.h>charfun(floatf){/**/floatc;c=5.0/9*(f-32);if(c<0)return'W';elseif(c<25)return'B';elseif(c<35)return'O';elsereturn'R';/**/voidmain()floatf;charcode;printf("\nPleaseinputtheFahrenheittemperature:");scanf("%f",&f);code=fun(f);printf("\n%c\n",code);getch();#include<stdio.h>#include<math.h>doublef(floatx)/**/floaty;if(x<=1600)y=0;elseif(x<=2100)y=(x-1600)*0.05;elseif(x<=3100)y=(x-1600)*0.1-25;elsey=(x-1600)*0.15-125;returny;/**/}voidmain(){floatx;doubley;clrscr();printf("Pleaseinputanumber:\n");scanf("%f",&x);y=f(x);printf("f(%.2f)=%.2f\n",x,y);精心整理精心整理精心整理getch();}#include<stdio.h>#defineROW4#defineCOL4intfun(inta[][COL],introw,intb[]){/**/inti,j,k=0;intsum=0;for(i=0;i<row;i++)for(j=0;j<COL;j++){if(a皿j]>0)b[k++]=a[i][j];if(a[i][j]==0)brea

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论