Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale>
- #include <fstream>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- // Удалить числа , равные минимальному
- int* form_massive(int count){
- int* massive = new int[count];
- int a = 0;
- time_t t;
- srand((unsigned)time(&t));
- while (a < count){
- massive[a] = rand()%10;
- cout << "massive [" << a << "] = " << massive[a] << endl;
- a++;
- }
- return massive;
- }
- void init_massive(int massive[], int &count){
- int a = 0, i = 1 , j = 0, n = 0,k=0, min=massive[1];
- while (i < count){
- if (massive[i] < min){
- min = massive[i];
- }
- i += 2;
- }
- i = 0;
- while (i < count-1){
- if (massive[i] == min){
- k = i;
- while (k < count-1){
- massive[k] = massive[k+1];
- k++;
- }
- j++;
- }
- i++;
- }
- count -= j;
- return;
- }
- void print_massive(int massive[], int count){
- cout << "Массив после обработки" << endl;
- for (int i = 0; i <= count - 1; i++){
- cout << "massive [" << i << "] = " << massive[i] << endl;
- }
- }
- void main(){
- int count, k;
- setlocale(LC_ALL, "rus");
- cout << "Введите кол-во элементов в массиве ";
- cin >> count;
- int* mas = form_massive(count);
- init_massive(mas, count);
- print_massive(mas, count);
- }
Advertisement
Add Comment
Please, Sign In to add comment