woed版
woed版-精品资料-
t[i]='\0'
t[i]='\0' ; }改为:t[j]='\0';
全国计算机等级考试 C语言一一改错题
m的值,计算如下公式的值:1给定程序中fun
m的值,计算如下公式的值:
1 1 1
t =1-
2*2 3*3m*m
例如,若m中的值为5,则应输出0.536389。
double fun (i nt m)
{ double y=1.0 ;
int i ;
************fo un d************
for(i=2 ; i
for(i=2 ; i
************fo un d************
y-=1/(i*i); return(y) ; } mai n()
{ int n=5 ;
改为:y-=1.0/(i*i);
printf("\nThe result is %lf\n" ,fun(n)) ; }
2?程序中fun函数功能是:将s字符串的正序和反序进行连接,形成一个新字符串放在t数组中。例如,当
s所指字符串为“ ABCD时,则t所指字符串的内容应为“ ABCDDCBA。
**********fo un d**********
void fun (char s , char t) { int i , d;
d=strlen(s);
改为:void fun (char *s , char *t)
for (i=0 ; i
**********fo un d**********
t[2*d-1]='\0' ;}改为:t[2*d]='\0';
mai n()
{ char s[100] , t[100];
printf("\nPlease enter string S:") ; scanf("%s", s);
fun(s, t);
printf("\nThe result is: %s\n" , t);}
3?给定程序中fun函数的功能是:将 s所指字符串中位于奇数位置的字符或ASCII码为偶数的字符放入 t
所指数组中(规定第一个字符放在第0位中)。例如:字符串中的数据为:AABBCCDDEEFF,则应输出
ABBCDDEFF 。
#defi ne N 80
void fun(char *s , char t[])
{ int i , j=0 ;
for(i=0 ; i
*********fo un d********
if(i%2 && s[i]%2= =0)
t[j++]=s[i];
改为:if(i%2= =0 || s[i]%2= =0)
*********fo un d********
改为:for(i=2 ; i<=m ; i++)
woed版
woed版-精品资料-
mai n(){ char s[N] , t[N]
mai n()
{ char s[N] , t[N];
printf("\nPlease enter string s : "); gets(s);
fun(s, t);
printf("\nThe result is : %s\n", t); }
给定程序中fun函数的功能是:计算 n!。例如,给n输入5,则输出120.000000。
#in clude
double fun (i nt n)
{ double result=1.0 ;
**********fo un d**********
if n== 0改为:if (n == 0)
if n== 0
return 1.0 ;
while(n >1 && * 170)
**********fo un d**********
**********fo un d**********
result *= n--改为:result *= n--;
result *= n--
retur n result ;
} mai n()
{ int n ;
printf("Input N:");
scanf("%d", &n);
printf("\n\n%d! =%lf\n