Guest User

Untitled

a guest
May 12th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ifstream dane("liczby.txt");
  10.     ofstream wynik("wynik6.txt");
  11.     int i=0;
  12.     int licznik=0;
  13.     string array[1000];
  14.     while(i<1000)
  15.     {
  16.         dane >> array[i];
  17.         i++;
  18.     }
  19.     string m=array[0];
  20.     int k= m.length();
  21.     cout << m;
  22.     int j=1;
  23.     while(j<1000)
  24.     {
  25.         int dl=array[j].length();
  26.         if(k<dl)
  27.         {
  28.             m=array[j];
  29.         }
  30.         if(k==dl)
  31.         {
  32.             for(int i=0;i<dl;i++)
  33.             {
  34.                 if(array[j][i]>m[i]) m=array[j];
  35.             }
  36.         }
  37.         j++;
  38.     }
  39.     cout << m << endl;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment