全国计算机改错,全国计算机等级考试C语言――改错题.docx

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值