Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- bool so (string wzor,string s)
- {
- bool spra = true;
- int dl = wzor.length();
- int dl2 = s.length();
- for(int i=0; i<dl; i++)
- {
- for(int j=0; j<dl-1; j++)
- {
- if(wzor[j] > wzor[j+1])
- {
- swap(wzor[j],wzor[j+1]);
- }
- }
- }
- for(int i=0; i<dl2; i++)
- {
- for(int j=0; j<dl2-1; j++)
- {
- if(s[j] > s[j+1])
- {
- swap(s[j],s[j+1]);
- }
- }
- }
- if(wzor != s)
- {
- spra = false;
- }
- return spra;
- }
- int main()
- {
- ifstream wej;
- ofstream wyj;
- ofstream wyj2;
- wej.open("ana.txt");
- wyj.open("odp1.txt");
- wyj2.open("odp2.txt");
- string ana;
- string tab[5];
- int tab2[5];
- for(int x=0; x<200; x++)
- {
- int length = 0;
- bool spr = true;
- for(int i=0; i<5; i++)
- {
- wej>>tab[i];
- tab2[i] = tab[i].length();
- }
- for(int i=0; i<5; i++)
- {
- length = tab2[0];
- if(length != tab2[i])
- {
- spr = false;
- }
- }
- if(spr != false)
- {
- int suma = 0;
- for(int i=0; i<5; i++)
- {
- suma+= so(tab[0],tab[i]);
- wyj<<tab[i]<<" ";
- }
- wyj<<endl;
- if(suma == 5)
- {
- for(int q=0; q<5; q++)
- {
- wyj2<<tab[q]<<" ";
- }
- wyj2<<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement