https://i0.wp.com/eblogarithm.com/wp-content/uploads/2016/12/Codeforces-Round-385-Div-2-problem-A-Hongcow-Learns-the-Cyclic-Shift-Solution-in-CC1.png?fit=640%2C360

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

#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;
}
(Visited 89 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: