Guest User

Untitled

a guest
Jun 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <110ct.h>
  3.  
  4. using namespace std;
  5.  
  6. void swapper (int arr1[], int arr2[]);
  7. int reverser (int arr2[], int i, int j);
  8.  
  9. ColourController cl;
  10.  
  11. int pos, i, j;
  12.  
  13. int main ()
  14. {
  15. int arr1[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  16. int arr2[10] = {1, 7, 9, 21, 84, 104, 56, 32, 91, 62};
  17.  
  18. cl.setForeground (Yellow);
  19. cout << "Reversing the Elements in an Array: \n\n";
  20.  
  21. for (int i = 0; i < 10; ++i)
  22. {
  23. cl.setForeground (White);
  24. cout << arr2[i] << " ";
  25. }
  26.  
  27. cout << endl;
  28. cl.setForeground (Green);
  29. cout << "Please hit the enter key to reverse the elements seen in the array. \n";
  30. cout << endl;
  31. swapper (arr1, arr2);
  32. qin.get();
  33. cl.setForeground (Red);
  34. cout << endl << endl;
  35. cout << "Thank you for using the array reverser. \n";
  36.  
  37. cin.ignore (2);
  38. return 0;
  39. }
  40.  
  41. void swapper (int arr1[], int arr2[])
  42. {
  43. int j = 9;
  44. for (int i = 0; i < 10; ++i, --j)
  45. {
  46. arr1[j] = arr2[i];
  47. }
  48. for (int i = 0; i < 10; ++i)
  49. {
  50. arr2[i] = arr1[i];
  51. }
  52. qin.get();
  53. for (int i = 0; i < 10; ++i)
  54. {
  55. cl.setForeground (Aqua);
  56. cout << arr2[i] << " ";
  57. }
  58. }
Add Comment
Please, Sign In to add comment