4 条题解

  • 3
    @ 2023-8-21 14:20:14

    两种语言(~ ̄▽ ̄)~

    1.c++代码

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        string str;
        char c;
        cin >> str >> c;
        for (int i = 0; i < str.size(); i++) if (str[i] != c) cout << str[i];
        return 0;
    }
    

    2.python代码

    s = input()
    c = input()
    for i in s:
        if i != c:
            print(i,end = '')
    
    • 1
      @ 2023-10-5 20:33:18
      #include<bits/stdc++.h>
      using namespace std;
      string s;
      char a;
      int main()
      {
          cin>>s>>a;
          for(int i=0;i<s.size();i++)
          {
              if(s[i]!=a)
              {        
                  cout<<s[i];
              }
          }
          return 0;
      }
      
      • 1
        @ 2023-7-8 14:38:06
        #include <bits/stdc++.h>
        using namespace std;
        
        int main(){
        	string s;
        	char c;
        	cin>>s>>c;
        	
        	//假删除:遍历每个字符,除了要删除的字符c以外,剩余的输出 
        	int i;
        	for(i = 0;i < s.size();i++){
        		if(s[i] != c){
        			cout<<s[i];
        		}
        	} 
        }
        
        
        • -1
          @ 2023-2-19 15:56:54
          #include <bits/stdc++.h>
          using namespace std;
          string s;
          char c;
          int main()
          {
              cin>>s;
              cin>>c;
          	int p=s.find(c);
          	while(p!=string::npos)
          	{
          		s.erase(p,1);
          		p=s.find(c);
          	}
          	cout<<s;
              return 0;
          }//以AC
          
          • 1

          信息

          ID
          131
          时间
          1000ms
          内存
          16MiB
          难度
          1
          标签
          递交数
          72
          已通过
          55
          上传者