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

请补充函数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=【 】;j<n;j++)

if (s[i]<s [j])

{

ch=s [j];

【 】;

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);

}


相关考题:

以下函数 fun 的功能是返回 str 所指字符串中以形参 c 中字符开头的后续字符串的首地址 , 例如 : st r所指字符串为 : Hello! , c 中的字符为 e ,则函数返回字符串 : ello! 的首地址。若 str 所指字符串为空串或不包含 c 中的字符,则函数返回 NULL 。请填空。char *fun(char *str,char c){ int n=0; char *p=str;if(p!=NULL)while(p[n]!=cp[n]!='\0') n++;if(p[n]=='\0') return NULL;return( 【 1 2 】 );}

请补充函数fun(),该函数的功能是:把ASCII码为奇数的字符从字符串str中删除,结果仍然保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdef”,输出“bdf”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun(char s[],int n){int i, j;j=0;for(i=0;【 】;i++){if(【 】)s [j++]-s [i];}【 】;}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);}

以下函数fun的功能是返回str所指字符串中以形参c中字符开头的后续字符串的首地址,例如,str所指字符串为Hello!,c中的字符为e,则函数返回字符串ello!的首地址。若str所指字符串为空或不包含c中的字符,则函数返回NULL,请填空。char *fun(char *str,char c){ int n=0; char *p=str; if(p!=NULL) while(p[n]!=cp[n]!=’\0’) n++; if(p[n]==’\0’) return NULL; return();}

请补充函数fun(),该函数的功能是:把ASCⅡ码为偶数的字符从字符串s打中删除,结果仍然保存在字符串srt中,字符串str从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdef”,输出“ace”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:inc lude< stdio, h>define N 80【 】{int i, j;【 】for (i=0;i<n;i++){if (s [i] %2!=0)s [j++]=s [i];}【 】;}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);}

请补充函数fun(),该函数的功能是:把字符下标能铍2或3整除的字符从字符串str中删除,把剩余的字符重新保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdefghijk”,输出“bfh”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun(char s[], int n){int i, k;【 】;for(i=0; i<n; i++){s[k++]=s[i];if(【 】)k--;}【 】;}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);}

请编一个函数fun(char*str),该函数的功能是把字符串中的内容逆置。 例如,字符串中原有的字符串为asdfg,则调用该函数后,串中的内容为gfdsa。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。 试题程序:

请编写函数proc(),对长度为9个字符的字符串,除首、尾字符外,将其余7个字符按ASCⅡ码值降序排列。例如,原来的字符串为HabcdefA,则排序后输出为HfedcbaA。 注意:部分源程序给出如下。 请勿改动main()和其他函数中的任何内容,仅在函数proc()中填入所编写的若干语句。 试题程序:

请补充fun()函数,该函数的功能是:把字符的ASCII码中为奇数的字符从字符串str中删除,结果仍然保存在字符串str中,字符串str从键盘输人,其长度作为参数传人fun()函数。例如,输入“abcdef”,则输出“bdf”。注意:部分源程序给出如下。请勿改动main()函数和其他函数中的任何内容,仅在mare()函数的横线上填入所编写的若干表达式或语句。试题程序:

请补充函数proc(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码升序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传人。例如,如果输入“9fedcba”,则输出为“abcdefg”。注意:部分源程序给出如下。请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。试题程序: