文档介绍:改错
1、取{2m, 3n |m≥1,n≥1}中由小到大排列的前70项数。
#include<>
void main( )
{double m,n;
int k;
/**********error************/
m=2, n=3;
for(k=0;k<70;k++)
/**********error************/
if(n<m)
{printf("%",m);
m*=2; }
else
{printf("%",n);
n*=3; }
return;
}
m=2;n=3;
if(m<n)
2、求 1- 1/2+1/3-1/4+…+ 1/99-1/100 的值。
#include<>
void main()
{int i,t;
float s=0;
for (i=t=1;i<=100;i++)
{
/***********error*************/
s+=t/i;
t=-t;
}
/***********error************/
printf("s=%d\n",s);
}
s+=(float)t/i;
printf("s=%f\n",s);
3、任意输入一串字符,以“?”结束,分别统计其中字母、数字和其他字符的个数。
#include<>
void main()
{char c;
int n1=0,n2=0,n3=0;
/***********error************/
for((c=getchar())!='?')
/***********error************/
if((c>='A'&&c<='Z')&&(c>='a'&&c<='z'))n1++;
else if(c>='0'&&c<='9')n2++;
else n3++;
printf("%d,%d,%d\n",n1,n2,n3);
}
for(;(c=getchar())!='?';)
if((c>='A'&&c<='Z')||(c>='a'&&c<='z'))n1++;
7、程序的功能是把两个字符串连接起来,请改正程序中的错误。
#include<>
void main()
{ char s1[100],s2[40];
int i=0,j=0;
printf("\n please input string1\n");
scanf("%s",s1);
printf(" please input string2\n");
scanf("%s",s2);
while(s1[i]!='\0')
i++;
/*****