Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring>
- using namespace std;
- int SortCuv(char cuv[])
- {
- char aux;
- int n = strlen(cuv);
- for(int i = 0; i < n-1; i++)
- for(int j = i+1; j < n; j++)
- {
- if(cuv[i] > cuv[j])
- {
- aux = cuv[i];
- cuv[i] = cuv[j];
- cuv[j] = aux;
- }
- }
- }
- int main()
- {
- ifstream fin("intrare.txt");
- ofstream fout("iesire.txt");
- char cuv1[255], cuv2[255], c1[255], c2[255];
- while(!fin.eof())
- {
- fin>>cuv1;
- fin>>cuv2;
- //cout<<"Inainte de sortare:"<<cuv1<<" "<<cuv2<<endl;
- strcpy(c1, cuv1);
- strcpy(c2, cuv2);
- SortCuv(cuv1);
- SortCuv(cuv2);
- //cout<<"Dupa sortare:"<<cuv1<<" "<<cuv2<<endl;
- if (!strcmp(cuv1, cuv2))
- fout<<c1<<" "<<c2<<endl;
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement