Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <iterator>
  6. #include <sstream>
  7. using namespace std;
  8.  
  9. istream & operator >> (istream & in, vector<long long int> & v)
  10. {
  11.     string str;
  12.     getline(in,str);
  13.     stringstream stream(str);
  14.     int tmp;
  15.     while(stream >> tmp)
  16.         v.push_back(tmp);
  17.     return in;
  18. }
  19. ostream & operator << (ostream & out, vector<long long int> const & v)
  20. {
  21.     for(long long int el: v)
  22.         out << el << ' ';
  23.     return out;
  24. }
  25. int main()
  26. {
  27.     long long int i,n,x,m,k,j,t,b,ma,mi;
  28.     vector<long long int> a;
  29.     cin>>a;
  30.     cin>>k;
  31.     b=k%a.size();
  32.     if (k>0){
  33.         for(i=a.size()-b;i<a.size();++i)
  34.             cout<<a[i]<<" ";
  35.         for(i=0;i<a.size()-b;++i)
  36.         {
  37.             cout<<a[i]<<" ";
  38.         }
  39.     }
  40.     if (k<0){
  41.             b=abs(b);
  42.             for(i=b;i<a.size();++i)
  43.             {
  44.                 cout<<a[i]<<" ";
  45.             }
  46.             for(i=0;i<b;++i)
  47.             {
  48.                 cout<<a[i]<<" ";
  49.             }
  50.     }
  51.     if (k==0) cout<<a;
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement