Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication28.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- void add(int* tab1,int* tab2, int r)
- {
- for (int a = 0; a < r; a++)
- {
- tab1[a] += tab2[a];
- }
- }
- void printTab(int* tab, int r)
- {
- cout << "\n\nSuma tablic:\n";
- for (int a = 0; a < r; a++)
- {
- cout << tab[a] << " ";
- }
- cout << "\n";
- }
- int main()
- {
- int min, max, a, r;
- cout << "Podaj rozmiar tablic\n";
- cin >> r;
- int * tab = new int[r];
- int * tab2 = new int[r];
- cout << "Podaj zakres losowania liczb dla pierwszej tablicy\n";
- cin >> min >> max;
- srand(time(0));
- cout << "Pierwsza tablica\n\n";
- for (a = 0; a < r; a++)
- {
- tab[a] = min + rand() % (max - min + 1);
- cout << tab[a] << " ";
- }
- cout << "\n\nPodaj zakres losowania liczb dla drugiej tablicy\n";
- cin >> min >> max;
- cout << "Druga tablica\n\n";
- for (a = 0; a < r; a++)
- {
- tab2[a] = min + rand() % (max - min + 1);
- cout << tab2[a] << " ";
- }
- add(tab, tab2, r);
- printTab(tab, r);
- delete[] tab;
- delete[] tab2;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement