Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. void PrintMassiv(int a[], int N)
  4. {
  5.     for (int i = 0; i < N; i++)
  6.     {
  7.         std::cout << a[i] << " ";
  8.     }
  9.     std::cout << "\n";
  10. }
  11.  
  12.  
  13. void main()
  14. {
  15.     int arr[100];
  16.     int temp[100];
  17.     int N;
  18.     int k;
  19.     int count = 0;
  20.  
  21.     std::cout << "Enter N: ";
  22.     std::cin >> N;
  23.  
  24.     std::cout << "Enter elements of array: ";
  25.     for (int i = 0; i < N; i++)
  26.         std::cin >> arr[i];
  27.  
  28.     std::cout << "Enter k: ";
  29.     std::cin >> k;
  30.  
  31.     for (int i = 0; i < N; i++)
  32.     {
  33.         if (arr[i] % k != 0)
  34.         {
  35.             temp[count] = arr[i];
  36.             count++;
  37.         }
  38.     }
  39.  
  40.     for (int i = 0; i < count; i++)
  41.         arr[i] = temp[i];
  42.  
  43.     PrintMassiv(arr, count);
  44.  
  45.     system("pause");
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement