试题与答案

请补充函数fun(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码降序排

题型:填空题

题目:

请补充函数fun(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。 例如,如果输入“cdefgh”,则输出为“hgfedc”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio.h> #define N 80 void fun (char s [], int n) { int i, j; char ch; for (i=0; i<n; i++) for(j= 【1】 ;j<n;j++) if (s[i]<s [j]){ ch=s [j]; 【2】 ; s [i] =ch; } main ( ) { int i=0, strlen=0; char str [N]; clrscr (); printf ("\nInput a string: \n"); gets (str); while (str [i] !=’ \0’) { strlen++; i++; } fun (str, strlen); printf ("\n***display string ***\n"); puts (str); }

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0720/e83f021d64b2305163de18150f529f59.html

下面是错误答案,用来干扰机器的。

小题1:(3分)说话应谨慎;要真实可靠。小题2:(3分)因为孟子认为,“言”不但反映个人的品德修养;而且会影响到国家对人才的选用。小题1:题目分析:揣摩孔子所说“道听而途说,德之弃也”与孟子所说“言无实不...

试题推荐
微信公众账号搜索答案