Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Даны два массива: А[M] и B[N] (M и N вводятся с клавиатуры).
- #include "stdafx.h"
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- using namespace std;
- int Vvod_chisel(char *);
- void Init(int *, int, char *);
- void Print(int *, int, char *);
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(LC_ALL, "Russian");
- int n, m, *A, *B;
- do
- {
- m = Vvod_chisel("Введите размер первого массива = ");
- n = Vvod_chisel("Введите размер второго массива = ");
- } while (n <= 0 && m <= 0);
- A = new int[m];
- B = new int[n];
- srand(time(NULL));
- Init(A, m, "Создание первого массива...");
- Init(B, n, "Создание второго массива...");
- Print(A, m, "Созданный первый массив");
- Print(B, n, "Созданный второй массив");
- delete[]A;
- delete[]B;
- }
- int Vvod_chisel(char *ms)
- {
- cout << ms;
- char str[10];
- cin.getline(str, 10);
- return atoi(str);
- }
- void Init(int *mas, int n, char *ms)
- {
- cout << ms << endl;
- for (int i = 0; i < n; *mas++ = rand() % 30 + -10, i++);
- }
- void Print(int *mas, int n, char *ms)
- {
- cout << ms << endl;
- for (int i = 0; i < n; cout.width(3), cout << *mas++, i++);
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement