Advertisement
DawidBartoszek3bTI

Zadanie 11

Apr 17th, 2020
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. void show(int n, int *tab)
  6. {
  7.  while(n--)
  8.  {
  9.    cout.width(4);
  10.    cout<<*tab++<<" ";
  11.  }
  12.    cout<<endl;
  13. }
  14. void random(int *a, int *b, int n, int max)
  15. {
  16.  while(n--)
  17.  {
  18.    *a++ = rand()%(max+1);
  19.    *b++ = rand()%(max+1);
  20.  }
  21. }
  22. int main()
  23. {
  24.  srand(time(0));
  25.  int a[10], b[10], c[10], max;
  26.     cout << "Max: ";
  27.     cin >> max;
  28.  random (a,b,10,max);
  29.  for(int i=0;i<10;++i)
  30.  {*(c+i) = *(a+i) + *(b+i);}
  31.     show(10,a);
  32.     show(10,b);
  33.     show(10,c);
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement