请编写函数fun,其功能是:将s所指字符串中除了下标为偶数、 同时ASCII值也为偶数的字符外,其余的全都删除;串中剩余字符所形成的一个新串放在t所指的一个数组中。
/*请编写函数fun,其功能是:将s所指字符串中除了下标为偶数、
同时ASCII值也为偶数的字符外,其余的全都删除;串中剩余字符所形成的一个新串放在t所指的一个数组中。 */
#include <stdio.h>
void fun(char *s,char *t)
{
int i=0,j=0;
while(s[i] != '\0')
{
if(i %2==0 && s[i] %2 ==0)
{
t[j++]=s[i];
}
i++;
}
t[j]='\0';
}
int main()
{
char s[100],t[100];
printf("Please enter a string of characters\n");
scanf("%s",s);
fun(s,t);
printf("%s\n",t);
return 0;
}