📄 1810645_ac_0ms_32k.c
字号:
# include <stdio.h>
# include <string.h>
char str[200],s[100],tmp[60][100],ch,swap[100];
char compute()
{
int i,j,temp,jinwei=0;
for(i = strlen(str) - 1; i > 0; i--)
{
temp = str[i] + s[i] - 96;
if(jinwei)
temp++;
if (temp > 9)
{
str[i] = temp + 38;
jinwei = 1;
}
else
{
str[i] = temp + 48;
jinwei = 0;
}
}
temp = str[i] + s[i] - 96;
if(jinwei)
temp++;
if (temp > 9)
str[i] = 'f';
else
str[i] = temp + 48;
return 'z';
}
main()
{
int i, j, n, mark;
while(scanf("%s",s) == 1)
{
mark = 0;
n = strlen(s);
strcpy(str,s);
strcpy(tmp[0],s);
for(i = 1; i < n; i++)
{
strcpy(swap,tmp[i-1]);
ch = swap[0];
strcpy(swap,&swap[1]);
swap[n-1] = ch;
strcpy(tmp[i],swap);
}
for(i = 2; i <= n; i++)
{
compute();
if(str[0] == 'f')
{
printf("%s is not cyclic\n",s);
break;
}
for(i = 1; i < n; i++)
if(strcmp(str,tmp[i]) == 0)
{mark = 1;break;}
if(mark) {printf("%s is cyclic\n",s);break;}
else {printf("%s is not cyclic\n",s);break;}
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -