Advertisement
eimkasp

C++ OLIMP masina (WIP)

Dec 7th, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <string.h>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int n, v = 0;
  11.     char a[256];
  12.     int Lst[50][50];
  13.     char word[20][256];
  14.     int i = 0;
  15.     bool ne = false;
  16.     string temp;
  17.     ifstream fd("masina.in");
  18.     ofstream fr("masina.out");
  19.     fd >> n;
  20.     fd.ignore(256,'\n');
  21.     while(!fd.eof()) {
  22.         i++;
  23.         fd.getline(a,256);
  24.         temp = a;
  25.         strcpy(word[i],a);
  26.         cout << word[i] << endl;
  27.        
  28.         //temp = word[i];
  29.         //cout << temp.size();
  30.     }
  31.     for (int j = 1; j <= n ; j++){
  32.         for(int k = 1; k <= n; k++) {
  33.     Lst[j][k] = 0;
  34.         }}
  35.  
  36.     for (int j = 1; j <= n; j++) {
  37.         temp = word[j];
  38.         //cout << temp.size();
  39.  
  40.         for (int k = j+1; k <= n; k ++){
  41.             for (int l = 0; l <= temp.size(); l++) {
  42.  
  43.                 if (word[j][l] == word[k][l] && k != j) {
  44.                     //cout << word[j][l]  << " " << word[j] << " " << word[k][l] << " " << word[k] << endl;
  45.                     Lst[j][k] ++;
  46.                     cout << Lst[j][k]<< " " << j << " " << k << endl;
  47.                     }
  48.                 else {cout << Lst[j][k]<< " " << j << " " << k << endl;
  49.                 break;
  50.                 }
  51.                 }
  52.         }
  53.     }
  54.        
  55. return 0;
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement