2017-01-29 11 views
-3

2つの文字列の一致する文字を検索し、残りの文字列と比較するN個の配列を持つプログラムを作成しようとしています。コードは次のとおりです。n文字列からサブ文字列を見つける方法

int main() 
{ 
    int a, b, n; 
    char sir[50]; 
    printf("Number of strings: "); scanf("%d", &n); 
    if(n<=1){ 
     printf("The program cannot run without at least 2 strings!"); 
    } else { 
     printf("The program will run for %d strings.\n", n); 
     printf("\nString number 1: "); 
     scanf("%s", &sir); 
     std::string first(sir); 
     cout << first; 
     for(a=2; a<=n;){ 
      printf("\nString number %d: ", a); 
      scanf("%s", &sir); 
      std::string temp(sir); 
      if(!!!first.contains(temp)!!!){ 
       a++; 
      } else { 
      printf("Program stops the substring doesn't match with the last string."); 
      return 0; 
      } 
     } 
    } 
} 

私はどこに!!!私はその部分をコード化する方法を知らない。

+0

:次の行は、仕事をする必要がありますか? –

+3

あなたはどんな問題を経験していますか?あなたのコードは、あなたがそれをすることを期待していないことは何ですか? –

+0

std :: coutとstd :: cin、xDの使い方が分かりません。はじめまして.... – Cravenica

答えて

0

ちょうどあなたの質問に答えるために:なぜあなたは `のstd :: cout`と`のstd :: cin`を使用していない

if(first.find(temp) != std::string::npos) 
関連する問題