请编写程序,其功能是:将s所指字符串中下标为偶数同时ASCII值为奇数的字符删除,s中剩余的字符形成的新串放在t所指的数组中。
例如,若s所指字符串中的内容为ABCDEFGl2345,其中字符C的ASCII码值为奇数,在数组中的下标为偶数,因此必须删除;而字符1的ASCII码值为奇数,在数组中的下标也为奇数,因此不应当删除,其他依此类推。最后t所指的数组中的内容应是BDFl2345。
并写出思路与流程图
#include <stdio.h>
#include <string.h>
int main()
{
char s[256],t[256];
gets(s);
int i,n = 0;
for(i = 0;i < strlen(s);i++){
if((i % 2 == 0 && s[i] % 2 == 0) || (i % 2 == 1)){
t[n++] = s[i];
}
}
t[n] = '\0';
for(i = 0;i < strlen(t);i++){
printf("%c",t[i]);
}
return 0;
}