请编写函数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;
}