Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void losuj(int *a, int *b, int n, int max)
- {
- while(n--)
- {
- *a++ = rand()%(max+1);
- *b++ = rand()%(max+1);
- }
- }
- void wyswietl(int n, int *tab)
- {
- while(n--)
- {
- cout.width(4); //znalazlam "opcje" ktora pozwala na rownomierne ulozenie tego - widac dokladniej sumowanie tego w tablicy c
- cout<<*tab++<<" ";
- }
- cout<<endl;
- }
- int main()
- {
- srand(time(0));
- int a[10], b[10], c[10], max;
- cout << "Wpisz max: ";
- cin >> max;
- losuj (a,b,10,max);
- for(int i=0;i<10;++i)
- {*(c+i) = *(a+i) + *(b+i);}
- wyswietl(10,a);
- wyswietl(10,b);
- wyswietl(10,c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement