#include<stdio.h>
#include<string.h>
void fun(char* s, char t[])
{
int i = 0;
int j = 0;
int n = strlen(s);
for (i = 0; i < n; i++)
{
if (i % 2 == 0 && ((int)s[i] % 2 == 0))
{
t[j++] = s[i];
}
}
t[j] = '\0';
}
int main()
{
char s[100], t[100];
printf("\n请输入 S:");
scanf("%s", s);
fun(s, t);
printf("\n结果为: %s\n", t);
}
将s所指字符串中除了下标为偶数、同时ASCI值也为偶数的字符外,其余的全都删除串中剩余字符所形成的一个新串放在t所指的数组中。
最新推荐文章于 2024-09-14 22:25:23 发布