Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. ifstream fin ("sortarecuvinte1.in");
  6. ofstream fout("sortarecuvinte1.out");
  7.  
  8. int main(){
  9. char v[205][31];
  10. int n = 0;
  11. while(fin >> v[n++])
  12. ;
  13. n --;
  14. for(int i=0; i < n ;++i)
  15. for(int j=i+1 ; j < n ;++j)
  16. if(strcmp(v[i],v[j])>0){
  17. char a[31];
  18. strcpy(a,v[i]);
  19. strcpy(v[i],v[j]);
  20. strcpy(v[j],a);
  21. }
  22.  
  23. for(int i=0;i<n;++i)
  24. fout << v[i] << endl;
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement