Advertisement
Racknoss

Сдвиг числа

Jul 25th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     setlocale(LC_ALL, "Russian");
  9.     const int n(7);
  10.     int Mass[n] = {0,0,0,0,0,0,0};
  11.     int Mass1[n] = {0,0,0,0,0,0,0};
  12.     int sd;
  13.     cout << "Введите число: ";
  14.     cin >> Mass[0];
  15.     for(short int df(0); df <= (n-1); df++)
  16.             {
  17.                 Mass[df+1] = Mass[df+1] + (Mass[df] / 10);
  18.                 Mass[df] = Mass[df] % 10;
  19.             }
  20.     cout << "Ваше число: " << endl;
  21.     for(int a(6); a >= 0; a--)
  22.     {
  23.         cout << Mass[a];
  24.     }
  25.     cout << endl;
  26.     cout << "Введите сдвиг: ";
  27.     cin >> sd;
  28.     sd = sd%7;
  29.     for(int a(0); a < 7; a++)
  30.     {
  31.         Mass1[(a+sd)%7] = Mass[a];
  32.     }
  33.     cout << "Ответ: " << endl;
  34.     for(int a(6); a >= 0; a--)
  35.     {
  36.         cout << Mass1[a];
  37.     }
  38.     _getch();
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement