Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void show(int n, int *tab)
- {
- while(n--)
- {
- cout.width(4);
- cout<<*tab++<<" ";
- }
- cout<<endl;
- }
- void random(int *a, int *b, int n, int max)
- {
- while(n--)
- {
- *a++ = rand()%(max+1);
- *b++ = rand()%(max+1);
- }
- }
- int main()
- {
- srand(time(0));
- int a[10], b[10], c[10], max;
- cout << "Max: ";
- cin >> max;
- random (a,b,10,max);
- for(int i=0;i<10;++i)
- {*(c+i) = *(a+i) + *(b+i);}
- show(10,a);
- show(10,b);
- show(10,c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement