Guest User

Untitled

a guest
May 20th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1.  #include<conio.h>
  2.  #include<fstream.h>
  3.  #include<iostream.h>
  4.  
  5.  
  6.  int main()
  7. {
  8.      
  9.   char imF[100],imM[100];  
  10.   int F=0,M=0;
  11.   ifstream weF("Female.txt");
  12.   ifstream weM("Male.txt");
  13.   ofstream wy("homosort.txt");
  14.  
  15.   weF>>imF; weM>>imM; //wczytywanie imion do tablic
  16.   while(! weF.eof() && !weM.eof())
  17.    {
  18.      if(strcmp(imF,imM)<0) //porównywanie imion
  19.            {
  20.             wy<<imF<<endl;
  21.             weF>>imF;
  22.             F++;
  23.            }
  24.          else
  25.            {
  26.             wy<<imM<<endl;
  27.             weM>>imM;
  28.             M++;
  29.            }
  30.    }
  31.    cout<<F<<" "<<M;
  32.    //zrzucanie reszty pliku.
  33. /* if (M>F)
  34.     wy<<imF<<endl;
  35.       else
  36.         wy<<imM<<endl;
  37.  */
  38.  if(F>M)
  39.    {
  40.       wy<<imF<<endl;    
  41.            while(! weF.eof())
  42.            {    
  43.                 weF>>imF;
  44.                 wy<<imF<<endl;
  45.            }
  46.    }
  47.  else
  48.    {
  49.       wy<<imM<<endl;
  50.            while(! weM.eof())
  51.            {    
  52.                 weM>>imM;
  53.                 wy<<imM<<endl;
  54.            }  
  55.     }
  56.    weF.close();
  57.    weM.close();
  58.    wy.close();
  59.    printf("\n");
  60.    system("pause");
  61.   }
Add Comment
Please, Sign In to add comment