时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:5758
解决:2611
题目描述:
输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。
输入:
测试数据有多组,每组输入字符串s和字符c。
输出:
对于每组输入,输出去除c字符后的结果。
样例输入:
heallo
a
样例输出:
hello
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
#define MAX 10000
int
main(void)
{
char str[MAX];
char c;
while(scanf("%s\n%c",str,&c)!=EOF)
{
int len = strlen(str);
int begin=0;
for(int i=0;i<len;i++)
{
if(str[i]==c)
{
}
else
{
str[begin]=str[i];
begin++;
}
}
for(int i=0;i<begin;i++)
printf("%c",str[i]);
printf("\n");
}
return 0;
}
/**************************************************************
Problem: 1049
User: ranchothu
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/