Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <locale>
- #include <time.h>
- #include <iomanip>
- using namespace std;
- void Print_mas(int* mass, int n){ //Функция для печати матрицы
- int i = 0;
- while (i < n){
- cout << setw(6) << mass[i] << " ";
- i++;
- }
- cout << endl;
- }
- int* form_mas(int count){
- int* massive = new int[count];
- int a = 0;
- while (a < count){
- massive[a] = rand() % 50;
- a++;
- }
- return massive;
- }
- void del(int* mass, int n){
- int a = n-1, i = 0, j = 0, prost = 0, b;
- int k = 0;
- for (i = 0; i<n; i++){
- while (a >= i){
- for (k = 2; (k < (abs(mass[a]) - 1)) && (prost == 0); k++){
- if (mass[a] % k == 0){
- prost = 1;
- j = i;
- }
- }
- if (prost == 0 && (abs(mass[a])>2)){
- for (b = a; b < n-1; b++){
- mass[b] = mass[b + 1];
- }
- n--;
- }
- a--;
- prost = 0;
- }
- a = n - 1;
- }
- cout << endl;
- cout << "Матрица после обработки : " << endl;
- cout << endl;
- Print_mas(mass, n);
- }
- void main()
- {
- int n, m, i = 0, j = 0;
- setlocale(LC_ALL, "rus");
- cout << "Введите кол-во столбцов в двумерном массиве" << endl;
- cin >> n;
- time_t t;
- srand((unsigned)time(&t));
- int* mass = form_mas(n);
- cout << "Исходная матрица : " << endl;
- Print_mas(mass, n);
- del(mass, n);
- }
Advertisement
Add Comment
Please, Sign In to add comment