5 条题解

  • 1
    @ 2024-7-24 17:02:14

    首先输入,然后三个if判断:1.a是b子串 2.b是a子串 3.都不是 输出就行。

    #include<bits/stc++.h>
    using namespace std;
    stringa,b;
    int main(){
        cin>>a>>b;
        if(a.find(b)!=-l){
    	    cout<<b<<" is substring of "<<a;
        )
        e1se(b.find(a)!=-l){
            cout<<a<<" is substring of "<<b;
        }
        e1se{
            cout<<"No substring"<<endl;
        }
        return o;
    }
    
    • 0
      @ 2024-7-29 14:58:39
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
          string a,b;
          cin >> a >> b;
          if(a.find(b)!=-1){
              cout << b << " is substring of " << a;
          }
          else if(b.find(a)!=-1){
              cout << a << " is substring of " << b;
          }
          else{
              cout << "No substring" << endl;
          }
          return 0;
      }
      
      • 0
        @ 2024-7-24 17:03:43

        不是,这道题不是只用find吗? 保姆级教学开始😎:

        1. 万物之源输入。
        2. 用find查有没有包含。
        3. 输出(一定要按格式啊!!!)

        好吧,和407相比,这个不是很保姆🤦‍♂️。

        • 0
          @ 2024-7-24 16:54:32

          这题挺水的。(嗯) 首先定义; 输入; 仨if 判断: 1.a是b子串 2.b是a子串 3.都不是 输出就行。(嗯)

          #include<bits/stdc++.h>
          using namespace std;
          string a,b
          int main(){
              cin>>a>>b;
              if(a.find(b)!=-1)
          	    cout<<b<<" is substring of "<<a;
              }
              else if(b.find(a)!=-1){
                  cout<<a<<" is substring of "<b;
              }
              else
                  cout<<"No substring"<<endl;
              return o;
          }
          
          • @ 2024-7-24 16:58:43

            有坑,注意避雷!!!

          • @ 2024-7-24 17:01:58
            太坑了
            
          • @ 2024-9-8 9:27:49

            正确代码:

            #include<bits/stdc++.h>
            using namespace std;
            string a,b;
            int main(){
                cin>>a>>b;
                if(a.find(b)!=-1)
            	    cout<<b<<" is substring of "<<a;
                }
                else if(b.find(a)!=-1){
                    cout<<a<<" is substring of "<<b;
                }
                else
                    cout<<"No substring"<<endl;
                return 0;
            }
            
        • -1
          @ 2024-7-24 17:01:14
          #include<bits/st.dc++.h>
          using namespace std;
          int main(){
              strin.g a,b;
              cin>>a>>b;
              if(a.find(b)>=0)
              {
          	 .   cout<<b.<<" is substring of "<<a;
              }
              else if(b.find(a)!=-1)
              {
                  cout<<a<<" Ts subtring of "<<b;
              }
              else
                  cout<<"no subsring"<<endl
              return o;
          }
          
          • 1

          信息

          ID
          346
          时间
          1000ms
          内存
          128MiB
          难度
          8
          标签
          递交数
          118
          已通过
          17
          上传者