Advertisement
Luca25

Untitled

Jul 6th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("input.txt");
  7. ofstream fout("output.txt");
  8.  
  9. int n, x, y, z, k, a, b;
  10.  
  11. int main() {
  12.     fin >> n;
  13.     char g[n], w[n];
  14.     fin >> g >> w;
  15.     for(x=0; x<n; x++){
  16.         if(g[x]!=w[x]){
  17.             a=1;
  18.         }
  19.     }
  20.     if(a==0){
  21.         fout << 1;
  22.         return 0;
  23.     }
  24.     a=0;
  25.     for(x=0; x<n; x++){
  26.         b=w[0];
  27.         for(y=0; y<n-1; y++){
  28.             w[y]=w[y+1];
  29.         }
  30.         w[n-1]=b;
  31.         for(z=0; z<n; z++){
  32.             if(w[z]!=g[z]){
  33.                 a=1;
  34.                 break;
  35.             }
  36.         }
  37.         if(a==0){
  38.             fout << 1;
  39.             return 0;
  40.         }
  41.         a=0;
  42.     }
  43.     fout << 0;
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement