MarcinKrol

Zad 11

May 13th, 2020
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <cstdlib>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int a, tabA[5], tabB[5], tabC[5];
  11. srand(time(NULL));
  12. cout<< "Podaj maksymalny zakres wylosowanych liczb(od 0 do): ";
  13. cin>>a;
  14. for (int i=0; i<5; i++)
  15. {
  16. tabA[i]=rand()%(a+1);
  17. tabB[i]=rand()%(a+1);
  18. tabC[i]=tabA[i]+tabB[i];
  19. }
  20. cout<<"Tablica A: ";
  21. for (int i=0; i<5; i++)
  22. {
  23. cout<<tabA[i]<<" ";
  24. }
  25. cout<<endl;
  26. cout<<"Tablica B: ";
  27. for (int i=0; i<5; i++)
  28. {
  29. cout<<tabB[i] << " ";
  30. }
  31. cout<<endl;
  32. cout<<"Tablica C: ";
  33. for (int i=0; i<5; i++)
  34. {
  35. cout<<tabC[i]<<" ";
  36. }
  37. cout<<endl;
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment