Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4.  
  5.  
  6. using namespace std;
  7. ifstream fin ("inlocuirecuvant.in");
  8. ofstream fout ("inlocuirecuvant.out");
  9.  
  10. int main()
  11. {
  12. int i=0,c,j=0;
  13. string s[250],s2[250],x,aux;
  14. while (fin >> x)
  15. {
  16. s[++i]=x;
  17. if (x[0]>='A' && x[0] <='Z')
  18. x[0]-=32;
  19. s2[i]=x;
  20. }
  21. c=i;
  22. for (i=1 ; i<c ; i++)
  23. for (j=i+1 ; j<=c ; j++)
  24. if (s2[i]>s2[j])
  25. {
  26. aux=s2[i];
  27. s2[i]=s2[j];
  28. s2[j]=aux;
  29. aux=s[i];
  30. s[i]=s[j];
  31. s[j]=aux;
  32. }
  33. for (i=1; i<=c ;i++)
  34. fout << s[i] << " " << endl;
  35. fin.close();
  36. fout.close();
  37. return 0;
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement