Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. const int n = 5;
  7. int a[n],b[n];
  8.  
  9. for (int i = 0; n > i; i++)
  10. {
  11. a[i] = rand() % 20+ (-10);
  12. cout << a[i] <<endl;
  13. }
  14. cout << endl;
  15.  
  16. for (int i = 0; n > i; i++)
  17. {
  18. if (a[i] < 0)
  19. {
  20. b[i] = a[i] * (-1);
  21. }
  22. else
  23. {
  24. b[i] = a[i];
  25. }
  26. cout << b[i] << endl;
  27. }
  28. system("pause");
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement