首页 > 试题广场 >

字符串清理

[问答题]

题目标题:

字符串清理

题目描述:

假定输入的字符串中只包含字母和*号。请编写函数fun,它的功能是:将字符串尾部的*号全部删除,前面和中间的*号不删除。

输入描述:

输入为一个字符串,字符串长度小于100

输出描述:

输出为清理后的字符串;

样式输入:

****A*BC*DEF*G*******

样式输出:

****A*BC*DEF*G

#include<stdio.h>
#include<string.h>
void fun(char a[])
{
int i,l=strlen(a);
for(i=l-1;a[i]=='*';i--)
a[i]=0;
}
int main()
{
char a[105];
gets(a);
fun(a);
printf("%s",a);
return 0;
}

发表于 2017-05-15 00:21:12 回复(0)