问答题

改错题 下列给定程序中,函数fun()的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码降序排序后输出。 例如:输入dafhc,则应输出hfdca。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include /**********************found***********************/ int fun(char t[ ]) { char c; int i,j; for(i=0;i
【参考答案】

(1)错误:int fun(char t[ ]) 正确:void fun(char t[ ])(2)错误: t[......

(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)

热门 试题

多项选择题
填空题请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:#include#include#define LEN 80main(){ char str1[LEN],str2[LEN]; char *p1=str1,*p2=str2; int i=0,j=0; clrscr(); printf( Enter the string: n ); scanf(【1】); printf( ***the origial string*** n ); while(*(p1+j)) { printf( 【2】 ,*(p1+j)); j++; } for(i=0;i<j;i+=2) *p2++=*(str1+i); *p2=’’ 0’’; printf( nThe new string is:%s n ,【3】);}