一道C语言题求解!

来源:百度知道 编辑:UC知道 时间:2024/05/14 03:56:08
题目是:
编写函数fun的功能是:将字符串中除了下标为奇数和ASCII值也是奇数的字符除外,其余所有的字符都删除。

用函数调用的方法做啊!

谢谢了哈!
就是输入一个数组的字符串,然后按要求删除相应位置的字符就可以了!

#include <stdio.h>
#include <string.h>

void fun( char *str )
{
int i=1;
int j=0;
int len = strlen( str );

for ( ; i<len; i+=2 )
{
if ( str[i] % 2 == 1 )
{
str[j] = str[i];
j++;
}
}
str[j] = '\0';
}

void main()
{
char str[] = "abcdeklmnoxyz";

fun( str );

}

题目还是不太明白 是不是作过滤功能程序?