RusSimona

pg 138 ex 80

Jun 28th, 2019
299
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<fstream>
  3. #include<cstring>
  4.  
  5. using namespace std;
  6.  
  7. ifstream fin("x.in");
  8.  
  9. void ordonare (char c1[100], char c2[100], char c3[100])
  10. {
  11. char aux[100];
  12. if (strcmp (c1, c2)>0)
  13. {
  14. strcpy (aux, c1);
  15. strcpy (c1, c2);
  16. strcpy(c2,aux);
  17.  
  18. }
  19. if (strcmp (c2, c3)>0)
  20. {
  21. strcpy (aux, c2);
  22. strcpy (c2, c3);
  23. strcpy(c3,aux);
  24.  
  25. }
  26. if (strcmp (c1, c2)>0)
  27. {
  28. strcpy (aux, c1);
  29. strcpy (c1, c2);
  30. strcpy(c2,aux);
  31.  
  32. }
  33. }
  34. char a[100], b[100], c[100];
  35. int main ()
  36.  
  37. {
  38. while (fin>>a>>b>>c)
  39. {
  40. ordonare(a,b,c);
  41. cout<<a<<" "<<b<<" "<<c;
  42. cout<<endl;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment