ChameL1oN

Лаба5_Задача1(Вар.10)

Dec 14th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <locale>
  3. #include <fstream>
  4. #include <stdlib.h>
  5. #include <time.h>
  6.  
  7. using namespace std;
  8.  
  9. // Удалить числа , равные минимальному
  10. int* form_massive(int count){
  11. int* massive = new int[count];
  12. int a = 0;
  13. time_t t;
  14. srand((unsigned)time(&t));
  15. while (a < count){
  16. massive[a] = rand()%10;
  17. cout << "massive [" << a << "] = " << massive[a] << endl;
  18. a++;
  19. }
  20. return massive;
  21. }
  22.  
  23. void init_massive(int massive[], int &count){
  24. int a = 0, i = 1 , j = 0, n = 0,k=0, min=massive[1];
  25. while (i < count){
  26. if (massive[i] < min){
  27. min = massive[i];
  28. }
  29. i += 2;
  30. }
  31. i = 0;
  32. while (i < count-1){
  33. if (massive[i] == min){
  34. k = i;
  35. while (k < count-1){
  36. massive[k] = massive[k+1];
  37. k++;
  38. }
  39. j++;
  40. }
  41. i++;
  42. }
  43. count -= j;
  44. return;
  45. }
  46.  
  47. void print_massive(int massive[], int count){
  48. cout << "Массив после обработки" << endl;
  49. for (int i = 0; i <= count - 1; i++){
  50. cout << "massive [" << i << "] = " << massive[i] << endl;
  51. }
  52. }
  53.  
  54. void main(){
  55. int count, k;
  56. setlocale(LC_ALL, "rus");
  57. cout << "Введите кол-во элементов в массиве ";
  58. cin >> count;
  59. int* mas = form_massive(count);
  60. init_massive(mas, count);
  61. print_massive(mas, count);
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment