福建省计算机二级C语言上机题解析.docx
《福建省计算机二级C语言上机题解析.docx》由会员分享,可在线阅读,更多相关《福建省计算机二级C语言上机题解析.docx(54页珍藏版)》请在冰豆网上搜索。
福建省计算机二级C语言上机题解析
第一部分:
程序修改题
#include
voidmain()
{charstr1[100],t[200];
inti,j;
/**/i=0;/**/改成j=0;
clrscr();
strcpy(str1,"4AZ18c?
Ge9a0z!
");
for(i=0;i{/**/if((str1[i]%2==0)&&(i%2!=0))/**/改成i%2==0{t[j]=str1[i];j++;}}t[j]='\0';printf("\nOriginalstring:%s\n",str1);printf("\nResultstring:%s\n",t);}#include#include#include#include#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));}#includevoidmain(){/**/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#include/**/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#includevoidmain(){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#includevoidmain(){chars[20]="tableleft100",t[20];/**/chartab[4,2]={{'a','f'},{'b','e'},{'e','a'},{'f','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#includemain(){charstr1[128];/**/inti,len;sum=0;/**/基本语法错误,改成inti,len,sum=0;printf("\nPleaseinputthestring:");gets(str1);len=strlen(str1);for(i=0;i{/**/if(str1[i]>='0'||str1[i]<='9')/**/逻辑错误,||改成&&sum++;}printf("%d\n",sum);getch();}#include#include#defineM8main(){inta[M],i;printf("Pleaseinput8numbers:\n");for(i=0;iscanf("%d",/**/a[i]/**/);输入列表项必须指定地址,改成&a[i]printf("Inverseorderis:\n");/**/for(i=M-1;i<=0;i--)/**/循环判断条件表示错误,改成i>=0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){/**/charstr1/**/;此处必须定义成字符数组,改成charstr1[50]inti,len,sum=0;printf("Pleaseinputastring:\n");scanf("%s",str1);len=strlen(str1);for(i=0;i{if(str1[i]>='A'&&str1[i]<='Z')/**/sum--;/**/改成sum++;}printf("%d\n",sum);getch();}#include#include/**/#includeM5/**/宏定义错误,改成#defineM5main(){inta[M],i;printf("Pleaseinput5numbers:\n");for(i=0;iscanf("%d",&a[i]);printf("Evennumbers:\n");for(i=0;i/**/if(a[i]/2==0)/**/判断偶数应该改成a[i]%2==0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){charstr1[128],str2[128];inti,len;gets(str1);len=strlen(str1);/**/for(i=0;i>len;i++)/**/循环条件表示错误,改成for(i=0;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();}#include#includevoidmain(){chars1[30]="People'sRepublicof",s2[]="China";char*ps1,*ps2;/**/ps1=NULL;/**/指针ps1指向字符串s1,改成ps1=s1;ps2=s2;/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成*ps1!='\0'ps1++;while(*ps2)*(ps1++)=*(ps2++);printf("\n%s\n",s1);getch();}#include#includevoidmain(){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]||a[1]+a[2]>a[0]||a[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#include/**/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+middle+small=100)/**/=改成=={n++;printf("%d-->large:%d,middle:%d,small:%d\n",n,large,middle,small);}}returnn;}voidmain(){intnum;num=fun();printf("\nThereare%dsolutions.\n",num);getch();}#includevoidmain(){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/**/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();}#includevoidmain(){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();}#includevoidmain(){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#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();}#includevoidmain(){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();}第二部分:程序填空题#includevoidmain(){/**/long/**/p;inti;p=1;/**/for/**/(i=1;i<=8;i++)p=p*i;printf("\np=%ld",p);getch();}#includevoidmain(){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#includeintmax,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);}#includevoidmain(){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);}}#includevoidmain(){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#includeintprime(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#include/**/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);}#includemain(){/**/char/**/str[20];inti;floatx;printf("Pleaseinputastring:\n");scanf("%s",/**/str/**/);i=0;while(str[i]){str[i]=/**/str[i]^15;/**/i++;}printf("\nTargetstring:%s\n",str);getch();}#includemain(){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;kavg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#includemain(){/**/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#includevoidsort(inta[],intm){inti,j,t,swap;for(i=0;i**/m-1/**/;i++){swap=0;for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
{
/**/if((str1[i]%2==0)&&(i%2!
=0))/**/改成i%2==0
t[j]=str1[i];
j++;
}
t[j]='\0';
printf("\nOriginalstring:
%s\n",str1);
printf("\nResultstring:
%s\n",t);
#defineM50
doublefun(intn)
{doubley=0.0;
j=0;
for(i=1;;i++)
/**/if((i<10)&&(i%3==0))/**/改成i>10
/**/y+=1/i;/**/改成y+=1.0/i;
if(j==n)break;
returny;
{clrscr();
printf("fun(8)=%8.3lf\n",fun(8));
/**/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();
/**/intfun();/**/该处不是函数说明,应该去掉分号
{inthen,cock,chicken,n=0;
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;
{intnum;
num=fun();
printf("\nThereare%dsolutions.\n",num);
{intm,n,result,flag=0;
/**/charch,/**/基本语法错误,逗号改成分号
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);
chars[20]="tableleft100",t[20];
/**/chartab[4,2]={{'a','f'},{'b','e'},{'e','a'},{'f','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;
printf("\nThesourcestring:
%s\n",s);
printf("\nThetargetstring:
main()
charstr1[128];
/**/inti,len;sum=0;/**/基本语法错误,改成inti,len,sum=0;
printf("\nPleaseinputthestring:
gets(str1);
len=strlen(str1);
for(i=0;i{/**/if(str1[i]>='0'||str1[i]<='9')/**/逻辑错误,||改成&&sum++;}printf("%d\n",sum);getch();}#include#include#defineM8main(){inta[M],i;printf("Pleaseinput8numbers:\n");for(i=0;iscanf("%d",/**/a[i]/**/);输入列表项必须指定地址,改成&a[i]printf("Inverseorderis:\n");/**/for(i=M-1;i<=0;i--)/**/循环判断条件表示错误,改成i>=0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){/**/charstr1/**/;此处必须定义成字符数组,改成charstr1[50]inti,len,sum=0;printf("Pleaseinputastring:\n");scanf("%s",str1);len=strlen(str1);for(i=0;i{if(str1[i]>='A'&&str1[i]<='Z')/**/sum--;/**/改成sum++;}printf("%d\n",sum);getch();}#include#include/**/#includeM5/**/宏定义错误,改成#defineM5main(){inta[M],i;printf("Pleaseinput5numbers:\n");for(i=0;iscanf("%d",&a[i]);printf("Evennumbers:\n");for(i=0;i/**/if(a[i]/2==0)/**/判断偶数应该改成a[i]%2==0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){charstr1[128],str2[128];inti,len;gets(str1);len=strlen(str1);/**/for(i=0;i>len;i++)/**/循环条件表示错误,改成for(i=0;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();}#include#includevoidmain(){chars1[30]="People'sRepublicof",s2[]="China";char*ps1,*ps2;/**/ps1=NULL;/**/指针ps1指向字符串s1,改成ps1=s1;ps2=s2;/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成*ps1!='\0'ps1++;while(*ps2)*(ps1++)=*(ps2++);printf("\n%s\n",s1);getch();}#include#includevoidmain(){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]||a[1]+a[2]>a[0]||a[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#include/**/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+middle+small=100)/**/=改成=={n++;printf("%d-->large:%d,middle:%d,small:%d\n",n,large,middle,small);}}returnn;}voidmain(){intnum;num=fun();printf("\nThereare%dsolutions.\n",num);getch();}#includevoidmain(){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/**/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();}#includevoidmain(){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();}#includevoidmain(){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#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();}#includevoidmain(){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();}第二部分:程序填空题#includevoidmain(){/**/long/**/p;inti;p=1;/**/for/**/(i=1;i<=8;i++)p=p*i;printf("\np=%ld",p);getch();}#includevoidmain(){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#includeintmax,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);}#includevoidmain(){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);}}#includevoidmain(){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#includeintprime(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#include/**/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);}#includemain(){/**/char/**/str[20];inti;floatx;printf("Pleaseinputastring:\n");scanf("%s",/**/str/**/);i=0;while(str[i]){str[i]=/**/str[i]^15;/**/i++;}printf("\nTargetstring:%s\n",str);getch();}#includemain(){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;kavg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#includemain(){/**/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#includevoidsort(inta[],intm){inti,j,t,swap;for(i=0;i**/m-1/**/;i++){swap=0;for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
/**/if(str1[i]>='0'||str1[i]<='9')/**/逻辑错误,||改成&&
sum++;
printf("%d\n",sum);
#defineM8
{inta[M],i;
printf("Pleaseinput8numbers:
\n");
for(i=0;iscanf("%d",/**/a[i]/**/);输入列表项必须指定地址,改成&a[i]printf("Inverseorderis:\n");/**/for(i=M-1;i<=0;i--)/**/循环判断条件表示错误,改成i>=0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){/**/charstr1/**/;此处必须定义成字符数组,改成charstr1[50]inti,len,sum=0;printf("Pleaseinputastring:\n");scanf("%s",str1);len=strlen(str1);for(i=0;i{if(str1[i]>='A'&&str1[i]<='Z')/**/sum--;/**/改成sum++;}printf("%d\n",sum);getch();}#include#include/**/#includeM5/**/宏定义错误,改成#defineM5main(){inta[M],i;printf("Pleaseinput5numbers:\n");for(i=0;iscanf("%d",&a[i]);printf("Evennumbers:\n");for(i=0;i/**/if(a[i]/2==0)/**/判断偶数应该改成a[i]%2==0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){charstr1[128],str2[128];inti,len;gets(str1);len=strlen(str1);/**/for(i=0;i>len;i++)/**/循环条件表示错误,改成for(i=0;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();}#include#includevoidmain(){chars1[30]="People'sRepublicof",s2[]="China";char*ps1,*ps2;/**/ps1=NULL;/**/指针ps1指向字符串s1,改成ps1=s1;ps2=s2;/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成*ps1!='\0'ps1++;while(*ps2)*(ps1++)=*(ps2++);printf("\n%s\n",s1);getch();}#include#includevoidmain(){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]||a[1]+a[2]>a[0]||a[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#include/**/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+middle+small=100)/**/=改成=={n++;printf("%d-->large:%d,middle:%d,small:%d\n",n,large,middle,small);}}returnn;}voidmain(){intnum;num=fun();printf("\nThereare%dsolutions.\n",num);getch();}#includevoidmain(){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/**/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();}#includevoidmain(){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();}#includevoidmain(){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#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();}#includevoidmain(){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();}第二部分:程序填空题#includevoidmain(){/**/long/**/p;inti;p=1;/**/for/**/(i=1;i<=8;i++)p=p*i;printf("\np=%ld",p);getch();}#includevoidmain(){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#includeintmax,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);}#includevoidmain(){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);}}#includevoidmain(){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#includeintprime(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#include/**/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);}#includemain(){/**/char/**/str[20];inti;floatx;printf("Pleaseinputastring:\n");scanf("%s",/**/str/**/);i=0;while(str[i]){str[i]=/**/str[i]^15;/**/i++;}printf("\nTargetstring:%s\n",str);getch();}#includemain(){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;kavg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#includemain(){/**/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#includevoidsort(inta[],intm){inti,j,t,swap;for(i=0;i**/m-1/**/;i++){swap=0;for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
scanf("%d",/**/a[i]/**/);输入列表项必须指定地址,改成&a[i]
printf("Inverseorderis:
/**/for(i=M-1;i<=0;i--)/**/循环判断条件表示错误,改成i>=0
printf("%d",a[i]);
/**/charstr1/**/;此处必须定义成字符数组,改成charstr1[50]
inti,len,sum=0;
printf("Pleaseinputastring:
scanf("%s",str1);
for(i=0;i{if(str1[i]>='A'&&str1[i]<='Z')/**/sum--;/**/改成sum++;}printf("%d\n",sum);getch();}#include#include/**/#includeM5/**/宏定义错误,改成#defineM5main(){inta[M],i;printf("Pleaseinput5numbers:\n");for(i=0;iscanf("%d",&a[i]);printf("Evennumbers:\n");for(i=0;i/**/if(a[i]/2==0)/**/判断偶数应该改成a[i]%2==0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){charstr1[128],str2[128];inti,len;gets(str1);len=strlen(str1);/**/for(i=0;i>len;i++)/**/循环条件表示错误,改成for(i=0;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();}#include#includevoidmain(){chars1[30]="People'sRepublicof",s2[]="China";char*ps1,*ps2;/**/ps1=NULL;/**/指针ps1指向字符串s1,改成ps1=s1;ps2=s2;/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成*ps1!='\0'ps1++;while(*ps2)*(ps1++)=*(ps2++);printf("\n%s\n",s1);getch();}#include#includevoidmain(){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]||a[1]+a[2]>a[0]||a[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#include/**/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+middle+small=100)/**/=改成=={n++;printf("%d-->large:%d,middle:%d,small:%d\n",n,large,middle,small);}}returnn;}voidmain(){intnum;num=fun();printf("\nThereare%dsolutions.\n",num);getch();}#includevoidmain(){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/**/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();}#includevoidmain(){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();}#includevoidmain(){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#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();}#includevoidmain(){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();}第二部分:程序填空题#includevoidmain(){/**/long/**/p;inti;p=1;/**/for/**/(i=1;i<=8;i++)p=p*i;printf("\np=%ld",p);getch();}#includevoidmain(){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#includeintmax,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);}#includevoidmain(){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);}}#includevoidmain(){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#includeintprime(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#include/**/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);}#includemain(){/**/char/**/str[20];inti;floatx;printf("Pleaseinputastring:\n");scanf("%s",/**/str/**/);i=0;while(str[i]){str[i]=/**/str[i]^15;/**/i++;}printf("\nTargetstring:%s\n",str);getch();}#includemain(){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;kavg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#includemain(){/**/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#includevoidsort(inta[],intm){inti,j,t,swap;for(i=0;i**/m-1/**/;i++){swap=0;for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
if(str1[i]>='A'&&str1[i]<='Z')
/**/sum--;/**/改成sum++;
/**/#includeM5/**/宏定义错误,改成#defineM5
inta[M],i;
printf("Pleaseinput5numbers:
for(i=0;iscanf("%d",&a[i]);printf("Evennumbers:\n");for(i=0;i/**/if(a[i]/2==0)/**/判断偶数应该改成a[i]%2==0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){charstr1[128],str2[128];inti,len;gets(str1);len=strlen(str1);/**/for(i=0;i>len;i++)/**/循环条件表示错误,改成for(i=0;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();}#include#includevoidmain(){chars1[30]="People'sRepublicof",s2[]="China";char*ps1,*ps2;/**/ps1=NULL;/**/指针ps1指向字符串s1,改成ps1=s1;ps2=s2;/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成*ps1!='\0'ps1++;while(*ps2)*(ps1++)=*(ps2++);printf("\n%s\n",s1);getch();}#include#includevoidmain(){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]||a[1]+a[2]>a[0]||a[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#include/**/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+middle+small=100)/**/=改成=={n++;printf("%d-->large:%d,middle:%d,small:%d\n",n,large,middle,small);}}returnn;}voidmain(){intnum;num=fun();printf("\nThereare%dsolutions.\n",num);getch();}#includevoidmain(){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/**/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();}#includevoidmain(){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();}#includevoidmain(){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#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();}#includevoidmain(){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();}第二部分:程序填空题#includevoidmain(){/**/long/**/p;inti;p=1;/**/for/**/(i=1;i<=8;i++)p=p*i;printf("\np=%ld",p);getch();}#includevoidmain(){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#includeintmax,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);}#includevoidmain(){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);}}#includevoidmain(){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#includeintprime(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#include/**/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);}#includemain(){/**/char/**/str[20];inti;floatx;printf("Pleaseinputastring:\n");scanf("%s",/**/str/**/);i=0;while(str[i]){str[i]=/**/str[i]^15;/**/i++;}printf("\nTargetstring:%s\n",str);getch();}#includemain(){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;kavg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#includemain(){/**/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#includevoidsort(inta[],intm){inti,j,t,swap;for(i=0;i**/m-1/**/;i++){swap=0;for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
scanf("%d",&a[i]);
printf("Evennumbers:
for(i=0;i/**/if(a[i]/2==0)/**/判断偶数应该改成a[i]%2==0printf("%d",a[i]);printf("\n");getch();}#include#includemain(){charstr1[128],str2[128];inti,len;gets(str1);len=strlen(str1);/**/for(i=0;i>len;i++)/**/循环条件表示错误,改成for(i=0;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();}#include#includevoidmain(){chars1[30]="People'sRepublicof",s2[]="China";char*ps1,*ps2;/**/ps1=NULL;/**/指针ps1指向字符串s1,改成ps1=s1;ps2=s2;/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成*ps1!='\0'ps1++;while(*ps2)*(ps1++)=*(ps2++);printf("\n%s\n",s1);getch();}#include#includevoidmain(){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]||a[1]+a[2]>a[0]||a[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#include/**/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+middle+small=100)/**/=改成=={n++;printf("%d-->large:%d,middle:%d,small:%d\n",n,large,middle,small);}}returnn;}voidmain(){intnum;num=fun();printf("\nThereare%dsolutions.\n",num);getch();}#includevoidmain(){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/**/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();}#includevoidmain(){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();}#includevoidmain(){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#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();}#includevoidmain(){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();}第二部分:程序填空题#includevoidmain(){/**/long/**/p;inti;p=1;/**/for/**/(i=1;i<=8;i++)p=p*i;printf("\np=%ld",p);getch();}#includevoidmain(){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#includeintmax,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);}#includevoidmain(){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);}}#includevoidmain(){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#includeintprime(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#include/**/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);}#includemain(){/**/char/**/str[20];inti;floatx;printf("Pleaseinputastring:\n");scanf("%s",/**/str/**/);i=0;while(str[i]){str[i]=/**/str[i]^15;/**/i++;}printf("\nTargetstring:%s\n",str);getch();}#includemain(){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;kavg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#includemain(){/**/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#includevoidsort(inta[],intm){inti,j,t,swap;for(i=0;i**/m-1/**/;i++){swap=0;for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
/**/if(a[i]/2==0)/**/判断偶数应该改成a[i]%2==0
charstr1[128],str2[128];
inti,len;
/**/for(i=0;i>len;i++)/**/循环条件表示错误,改成for(i=0;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();}#include#includevoidmain(){chars1[30]="People'sRepublicof",s2[]="China";char*ps1,*ps2;/**/ps1=NULL;/**/指针ps1指向字符串s1,改成ps1=s1;ps2=s2;/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成*ps1!='\0'ps1++;while(*ps2)*(ps1++)=*(ps2++);printf("\n%s\n",s1);getch();}#include#includevoidmain(){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]||a[1]+a[2]>a[0]||a[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#include/**/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+middle+small=100)/**/=改成=={n++;printf("%d-->large:%d,middle:%d,small:%d\n",n,large,middle,small);}}returnn;}voidmain(){intnum;num=fun();printf("\nThereare%dsolutions.\n",num);getch();}#includevoidmain(){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/**/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();}#includevoidmain(){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();}#includevoidmain(){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#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();}#includevoidmain(){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();}第二部分:程序填空题#includevoidmain(){/**/long/**/p;inti;p=1;/**/for/**/(i=1;i<=8;i++)p=p*i;printf("\np=%ld",p);getch();}#includevoidmain(){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#includeintmax,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);}#includevoidmain(){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);}}#includevoidmain(){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#includeintprime(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#include/**/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);}#includemain(){/**/char/**/str[20];inti;floatx;printf("Pleaseinputastring:\n");scanf("%s",/**/str/**/);i=0;while(str[i]){str[i]=/**/str[i]^15;/**/i++;}printf("\nTargetstring:%s\n",str);getch();}#includemain(){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;kavg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#includemain(){/**/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#includevoidsort(inta[],intm){inti,j,t,swap;for(i=0;i**/m-1/**/;i++){swap=0;for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
if(str1[i]>='0'&&str1[i]<='8')
str2[i]=str1[i]+1;
elseif(str1[i]=='9')
str2[i]='0';
else
str2[i]=str1[i];
/**/str2[i]='\n';/**/字符串的结束标识应该用'\0'表示
puts(str2);
chars1[30]="People'sRepublicof",s2[]="China";
char*ps1,*ps2;
/**/ps1=NULL;/**/指针ps1指向字符串s1,改成ps1=s1;
ps2=s2;
/**/while(*ps1==NULL)/**/判断是否到达串尾标识,应改成*ps1!
='\0'
ps1++;
while(*ps2)
*(ps1++)=*(ps2++);
printf("\n%s\n",s1);
floata[3],s,area;
inti;
printf("Pleaseinput3numbers:
for(i=0;i<3;i++)
scanf("%f",/**/a[i]/**/);输入列表项必须指定地址
/**/if(a[0]+a[1]>a[2]||a[1]+a[2]>a[0]||a[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);
printf("error.\n");
/**/voidfun()/**/此处说明函数有返回值,改成intfun()
intlarge,middle,small,n=0;
for(large=0;large<=33;large++)
for(middle=0;middle<=50;middle++)
small=2*(100-3*large-2*middle);
/**/if(large+middle+small=100)/**/=改成==
n++;
printf("%d-->large:
%d,middle:
%d,small:
%d\n",n,large,middle,small);
intnum;
/**/for(i=100;i<200;i++);/**/for语句错误,此处去掉分号
if((i-2)%4==0)
((i-3)%7))
if(i%9==5)
printf("%d\n",/**/&i/**/);去掉地址符号&
/**/voidswap(intp1,intp2)/**/改成voidswap(int*p1,int*p2)
inttemp;
temp=*p1;
/**/p1=p2;/**/改成*p1=*p2;
*p2=temp;
inta,b;
printf("pleaseinput2numbers:
scanf("%d%d",&a,&b);
printf("\nOriginal:
a=%db=%d\n",a,b);
swap(&a,&b);
printf("\nResult:
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);
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==result
printf("x=%d,y=%d,z=%d\n",x,y,z);
#defineF(x)(x*x-2.3*x+5.6)/(x+8.2)
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);
intf,s,t,n;
printf("\nThelistis:
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);
第二部分:
程序填空题
{/**/long/**/p;
p=1;
/**/for/**/(i=1;i<=8;i++)
p=p*i;
printf("\np=%ld",p);
inta,b,c;
floatf;
printf("Pleaseinputab:
f=/**/1.0*a/b/**/;
c=/**/(int)/**/(f*100)%10;
printf("\na/b=%fTheseconddecimalplaceis:
%d\n",f,c);
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;
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);
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);
intn,a,b;
/**/
a=0;
b=0;
scanf("%d",&n);
while(/**/n!
=0/**/)
if(n>0)a++;
else/**/b++;/**/
printf("Positiveinteger:
%d,negativeinteger:
%d\n",a,b);
intprime(intn)
{intk,flag=1;
for(k=2;k<=n/2+1;k++)
if(n%k==0){flag=/**/0/**/;break;}
returnflag;
{intnum,a;
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);
/**/main()/**/
{floatx,x0,f,f1;
x=1.5;
{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);
/**/char/**/str[20];
floatx;
scanf("%s",/**/str/**/);
i=0;
while(str[i])
str[i]=/**/str[i]^15;/**/
i++;
printf("\nTargetstring:
%s\n",str);
inta[5]={20,30,45,64,23};
floatm;
/**/floataverage(intpa[],intn);/**/
m=average(a,5);
printf("Average=%f\n",m);
floataverage(intpa[],intn)
{intk;
floatavg=0.0;
for(k=0;kavg=avg+/**/pa[k]/**/;avg=avg/n;returnavg;}#includemain(){/**/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#includevoidsort(inta[],intm){inti,j,t,swap;for(i=0;i**/m-1/**/;i++){swap=0;for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
avg=avg+/**/pa[k]/**/;
avg=avg/n;
returnavg;
/**/char/**/s[80];
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]);
voidsort(inta[],intm)
{inti,j,t,swap;
for(i=0;i**/m-1/**/;i++)
swap=0;
for(j=0;j{if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
if/**/(a[j]{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;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
swap=1;
t=a[j];
a[j]=/**/a[j+1]/**/;
a[j+1]=t;
swap)break;
inta[]={23,55,8,32,18,2,9};
inti,k=sizeof(a)/sizeof(int);
sort(a,k);
for(i=0;iprintf("%d",a[i]);printf("\n");getch();}#include#includeintfun(/**/floata,floatb,floatc/**/){floattemp;intbTrue=0;if(a{temp=a;a=b;b=temp;}if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
intfun(/**/floata,floatb,floatc/**/)
floattemp;
intbTrue=0;
if(a
{temp=a;
a=b;
b=temp;
if(a{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();}#includemain(){intx;printf("Pleaseinputanumber:\n");scanf("%d",/**/&x/**/);printf("%d*%d=%d\n",x,x,/**/x*x/**/);getch();}#include#include
a=c;
c=temp;
if(fabs(/**/a*a/**/-(b*b+c*c))<1.0e-15)
bTrue=1;
returnbTrue;
floata,b,c;
printf("Pleaseinputthreenumbers:
scanf("%f%f%f",&a,&b,&c);
if(fun(a,b,c)==1)
printf("Yes\n");
printf("No\n");
{intx;
printf("Pleaseinputanumber:
scanf("%d",/**/&x/**/);
printf("%d*%d=%d\n",x,x,/**/x*x/**/);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1