Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using namespace std;
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5.  
  6. int main()
  7. {
  8. char records = 2;
  9.  
  10. char temp[3] = { 0 };
  11. char a[2][3] = { 0 };
  12. /*char test[2][3];*/
  13.  
  14. cout << "\nEnter A0: ";
  15. cin.sync();
  16. cin.getline(a[0], 4);
  17. cin.sync();
  18. cout << endl;
  19.  
  20. cout << "\nEnter A1: ";
  21. cin.sync();
  22. cin.getline(a[1], 4);
  23. cin.sync();
  24. cout << endl;
  25.  
  26. /*cin >> test[0]
  27. >> test[1];*/
  28.  
  29.  
  30. for (char i = 0; i < records; i++)
  31. {
  32. for (char i2 = 0; i2 < records - i - 1; i2++)
  33. {
  34. if (strcmp(a[i], a[i + 1]) > 0)
  35. {
  36. strcpy_s(temp, a[i]);
  37. strcpy_s(a[i], a[i2]);
  38. strcpy_s(a[i2], temp);
  39.  
  40. }
  41. }
  42. }
  43.  
  44. cout << a[0] << "\n" << a[1] << "\n" ;
  45.  
  46.  
  47. /*<< test << "\n"*/
  48.  
  49. system("pause");
  50. return 0;
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement