链接:http://codeforces.com/contest/834/problem/A
Solution:
很简单的整除判断
因为太久没有写过代码怕出问题,写得非常累赘(暴力)
#include<stdio.h>
int ch(char a)
{
if (a=='^') return 1;
if (a=='>') return 2;
if (a=='v') return 3;
if (a=='<') return 4;
}
int main()
{
char a,b;
int n,r1,r2,i,j,tms;
bool cw,ccw;
scanf("%c %c",&a,&b);
scanf("%d",&n);
r1=ch(a);r2=ch(b);
i=r1,j=r2;
tms=0;
while (i!=j)
{
tms++;
if (i++==4) i=1;
}
cw=(tms<=n) && (((n-tms)&3)==0);
i=r1,j=r2;
tms=0;
while (i!=j)
{
tms++;
if (i--==1) i=4;
}
ccw=(tms<=n) && (((n-tms)&3)==0);
if (cw^ccw) puts(cw?"cw":"ccw") ;
else puts("undefined");
}
本文解析了CodeForces竞赛中的一道A级题目,通过一个简单的整除判断问题介绍了如何使用C语言进行编码实现。文章包含完整的代码示例及运行逻辑说明。

100

被折叠的 条评论
为什么被折叠?



