naquo

[SOLUCIÓN] OMI 2011 - Nivel 1 - Problema 3

Sep 8th, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.   int i;
  8.   int x;
  9.   int y;
  10.   int tl;
  11.  
  12.   cin >> tl;
  13.  
  14.   string l[tl];
  15.  
  16.   for (i=0; i<=(tl-1);  i++) {
  17.     cin >> l[i];
  18.   }
  19.  
  20.   int matriz[tl][tl];
  21.  
  22.   for (y=0; y<=(tl-1); y++) {
  23.     for (x=0; x<=(tl-1); x++) {
  24.       if(int(l[x].find (l[y]))!=l[x].npos) {
  25.         matriz[x][y]=1;
  26.       }
  27.     }
  28.   }
  29.  
  30.   for(y=0; y<=(tl-1); y++) {
  31.     for (x=0; x<=(tl-1); x++) {
  32.       if (x!=y && matriz[x][y]==1) {
  33.         cout << l[y] << " " << l[x] << endl;
  34.       }
  35.     }
  36.   }
  37.  
  38.   system("pause");
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment