Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<cstring>
- using namespace std;
- ifstream fin("sortarecuvinte1.in");
- ofstream fout("sortarecuvinte1.out");
- void sort(char A[][31], int n)
- {
- for(int i=2; i<=n; i++)
- {
- for(int j=i; j>=2; j--)
- {
- if(strcmp(A[j-1],A[j])==1)
- {
- char s[31];
- strcpy(s,A[j]);
- strcpy(A[j],A[j-1]);
- strcpy(A[j-1],s);
- }
- }
- }
- }
- char A[201][31];
- int main()
- {
- int cnt=0;
- while(fin>>A[++cnt])
- true;
- cnt--;
- sort(A,cnt);
- for(int i=1; i<=cnt; i++)
- fout<<A[i]<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement