C语言实验——删除指定字符

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 327  Solved: 211
[Submit][Status][Web Board]

Description

从键盘输入一个字符串给str和一个字符给c,删除str中的所有字符c并输出删除后的字符串str。

Input

第一行是一个字符串; 第二行是一个字符。

Output

删除指定字符后的字符串。

Sample Input

sdf$$$sdf$$
$

Sample Output

sdfsdf

HINT

 

 1 #include <iostream>
 2 #include <stdio.h>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     char s[101];
 8     char c;
 9     cin>>s;
10     getchar();
11     cin>>c;
12     getchar();
13     for(int i=0;s[i]!='\0';i++){
14         if(s[i]!=c)
15             cout<<s[i];
16     }
17     return 0;
18 }

 

Freecode : www.cnblogs.com/yym2013

相关文章:

  • 2022-12-23
  • 2021-08-23
  • 2022-02-09
  • 2021-06-12
  • 2021-11-16
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-26
  • 2022-12-23
  • 2022-01-20
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案