Siwy_Krzysiek

Matura 2014 Ciekawe napisy C

Dec 20th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int policz(ifstream& dane);
  8.  
  9. int main()
  10. {
  11.     ifstream dane("NAPIS.TXT");
  12.     string slowo;
  13.     //cout << policz(dane);
  14.  
  15.     //string katalog[policz(dane)];
  16.     string *katalog = new string [policz(dane)];
  17.  
  18.     for(int i=0; i<1000; i++)
  19.     {
  20.         dane >> slowo;
  21.         katalog[i] = slowo;
  22.     }
  23.  
  24.     for(int i=0; i<1000; i++)
  25.     {
  26.         string buffer = katalog[i];
  27.  
  28.         for(int j=i; j<1000; j++)
  29.         {
  30.             if(j!=i && katalog[i]==katalog[j]) cout << katalog[i] << endl;
  31.         }
  32.     }
  33.  
  34.  
  35.  
  36. //    for(int i=0; i<1000; i++)
  37. //    {
  38. //        cout << katalog[i] << endl;
  39. //    }
  40.  
  41.  
  42. //    cout << rosnie("ABB") << endl;
  43.  
  44. //    while(!dane.eof())
  45. //    {
  46. //
  47. //    }
  48.  
  49.     return 0;
  50. }
  51.  
  52. int policz(ifstream& dane)
  53. {
  54.     string slowo;
  55.     int i=0;
  56. //    dane >> slowo;
  57. //    cout << slowo << endl;
  58.     while(!dane.eof())
  59.     {
  60.         dane >> slowo;
  61.         i++;
  62.     }
  63.     dane.seekg(0);
  64.  
  65.     return i;
  66. }
Add Comment
Please, Sign In to add comment