daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Feb 12th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. main()
  8. {
  9.     fstream plik;
  10.     fstream odp1;
  11.     fstream odp2;
  12.  
  13.     plik.open("anagram.txt", ios::in);     
  14.     odp1.open("odp1.txt", ios::out | ios::app);
  15.     odp2.open("odp2.txt", ios::out | ios::app);
  16.  
  17.     string s1, s2, s3, s4, s5;
  18.     int i,j,f;
  19.    
  20.     for(f=0; f<200 ; f++)
  21.     {
  22.    
  23.     plik >> s1;
  24.     plik >> s2;
  25.     plik >> s3;
  26.     plik >> s4;
  27.     plik >> s5;
  28.  
  29.     if( (s1.size() == s2.size()) && (s1.size()== s3.size()) && (s1.size() == s4.size()) && (s1.size() == s5.size()))
  30.     {  
  31.         odp1 << s1 << " " << s2 << " " << s3 << " " << s4 << " " << s5 << " " << endl;
  32.    
  33.         for (i=0; i<s1.size()-1; i++)
  34.         for (j=0; j<s1.size()-1; j++)
  35.             if (s1[j]>s1[j+1])
  36.                 swap(s1[j], s1[j+1]);
  37.    
  38.         for (i=0; i<s2.size()-1; i++)
  39.         for (j=0; j<s2.size()-1; j++)
  40.             if (s2[j]>s2[j+1])
  41.                 swap(s2[j], s2[j+1]);
  42.    
  43.         for (int i=0; i<s3.size()-1; i++)
  44.         for (int j=0; j<s3.size()-1; j++)
  45.             if (s3[j]>s3[j+1])
  46.                 swap(s3[j], s3[j+1]);
  47.    
  48.         for (int i=0; i<s4.size()-1; i++)
  49.         for (int j=0; j<s4.size()-1; j++)
  50.             if (s4[j]>s4[j+1])
  51.                 swap(s4[j], s4[j+1]);
  52.  
  53.         for (int i=0; i<s5.size()-1; i++)
  54.         for (int j=0; j<s5.size()-1; j++)
  55.             if (s5[j]>s5[j+1])
  56.                 swap(s5[j], s5[j+1]);
  57.    
  58.         if( s1 == s2 && s1 == s3 && s1 == s4 && s1 == s5)
  59.         {
  60.        
  61.         odp2 << s1 << " " << s2 << " " << s3 << " " << s4 << " " << s5 << " " << endl;
  62.        
  63.         }
  64.     }
  65.  
  66.     s1.clear();
  67.     s2.clear();
  68.     s3.clear();
  69.     s4.clear();
  70.     s5.clear();
  71.    
  72.     }
  73.  
  74.     plik.close();
  75.     odp1.close();
  76.     odp2.close();  
  77.  
  78.     return 0;
  79.  
  80. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top