Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. // ConsoleApplication55.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10. bool palindrom(int n, string w)
  11. {
  12.     for (int i = 0; i < n/2; i++)
  13.         if (w[i] != w[n - i - 1])
  14.             return false;
  15.     return true;
  16. }
  17.  
  18. bool przesuniecie(int n, string w, int k)
  19. {
  20.     string nowy = w;
  21.     for (int i = 0; i < n; i++)
  22.         nowy[i] = w[(i + k) % n];
  23.     cout << nowy;
  24.  
  25.     return (palindrom(n, nowy));
  26. }
  27.  
  28.  
  29. int main()
  30. {
  31.     int n, k;
  32.     string txt;
  33.     cin >> n >> txt >> k;
  34.     //cout << palindrom(n, txt);
  35.     cout << przesuniecie(n, txt, k);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement