给定程序MODI1.C中函数fun的功能是:将s所指字
给定程序MODI1.C中函数fun的功能是:将s所指字符串中位于奇数位置的字符或ASCII码为偶数的字符放入t所指数组中(规定第一个字符放在第0位中)。
例如,字符串中的数据为:AABBCCDDEEFF,则输出应当是ABBCDDEFF。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
给定源程序:
#include <stdio.h>
#include <string.h>
#define N 80
void fun(char *s, char t[])
{int i, j=0;
for(i=0; i<(int)strlen(s); i++)
/***********found**********/
if(__1__)
t[j++]=s[i];
/***********found**********/
__2__;
}
main()
{char s[N], t[N];
printf("\nPlease enter string s : "); gets(s);
fun(s, t);
printf("\nThe result is : %s\n",t);
}答案
第1空:i%2||s[i]%2==0 / i%2!=0||s[i]%2==0
第2空:t[j]='\0' / t[j]=0