填空题

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

【参考答案】

[1]void fun(char s[],int n)