Codeforces Round #385 (Div. 2), problem: (A) Hongcow Learns the Cyclic Shift Solution in C/C++

By |2017-04-07T22:11:47+00:00December 18th, 2016|Categories: C/C++, Programming|Tags: , , |

#include<stdio.h> #include<string.h> void cycle(char s[],int len) { char temp=s[len-1]; int i; for(i=len-1;i>0;i--) { s[i]=s[i-1]; } s[0]=temp; } int main(){ char s[51],orig[51]; int len,count=0; scanf("%s",s); len=strlen(s); strcpy(orig,s); do { cycle(s,len); count++; } while(strcmp(orig,s)); printf("%d\n",count); return 0; }