Kosty_Fomin

Untitled

Jul 4th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4.  
  5. int main(int argc, const char * argv[]) {
  6.     long n,k,buf;
  7.     bool ch;
  8.     std::srand(std::time(0));
  9.    
  10.     std::cout<<"Input N:";
  11.     std::cin>>n;
  12.     std::cout<<"Input K:";
  13.     std::cin>>k;
  14.    
  15.     std::cout<<"If you want random generation - input 1\n If you want hand-made generation - input 0\n";
  16.     std::cin>>ch;
  17.     long* mas = new long[n];
  18.    
  19.     for(int i = 0; i<n; i++){
  20.         switch (ch) {
  21.             case 0:
  22.                 std::cin>>mas[i];
  23.                 break;
  24.             case 1:
  25.                 mas[i] = rand();
  26.                 break;
  27.             default:
  28.                 break;
  29.         }
  30.        
  31.     }
  32.    
  33.    
  34.    
  35.     for (int i = 0; i<n; i++) {
  36.         std::cout<<mas[i]<<" ";
  37.     }
  38.     std::cout<<"\n";
  39.    
  40.     for (int i = 0; i<k; i++) {
  41.         buf = mas[0];
  42.         for (int j = 0; j<n; j++) {
  43.             mas[j] = mas[j+1];
  44.         }
  45.         mas[n-1] = buf;
  46.     }
  47.    
  48.    
  49.    
  50.     for (int i = 0; i<n; i++) {
  51.         std::cout<<mas[i]<<" ";
  52.     }
  53.    
  54.     delete[] mas;
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment