UVA253-4.4(ti)-Cube painting
题目描述:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=833&problem=189&mosmsg=Submission+received+with+ID+18647764
这个题就是判断两个骰子是否一样。
题目分析:
拿三个函数模拟三种旋转方向,然后组合一下判断一下就可以了。
(挺简单的题,但是却写了半天,各种错误=。=不该在写代码的时候看游戏直播)
给出代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void A(char num[8]);
void B(char num[8]);
void C(char num[8]);
int main()
{
//freopen("D:\\out1put.txt","w",stdout);
char num1[8];
char num2[8];
memset(num1,0,sizeof(num1));
memset(num2,0,sizeof(num2));
char num3[15];
while(scanf("%s",num3)!=EOF)
{
int i,j;
for(i=0; i<6; i++)
num1[i]=num3[i];
for(j=0,i=6; num3[i]!='\0'; i++,j++)
num2[j]=num3[i];
int k=1;
k=strcmp(num1,num2);
//char num5[8];
//strcpy(num5,num2);
if(k==0)
{
printf("TRUE\n");
continue;
}
char num4[8];
strcpy(num4,num2);
if(k!=0)
for(i=1;i<=4;i++)
{
B(num4);
for(j=1;j<=4;j++)
{
A(num4);
k=strcmp(num4,num1);
if(k==0)
break;
}
if(k==0)
break;
}
strcpy(num4,num2);
if(k!=0)
for(i=1;i<=4;i++)
{
C(num4);
for(j=1;j<=4;j++)
{
A(num4);
k=strcmp(num4,num1);
if(k==0)
break;
}
if(k==0)
break;
}
if(k==0)
printf("TRUE\n");
else
printf("FALSE\n");
memset(num1,0,sizeof(num1));
memset(num2,0,sizeof(num2));
memset(num3,0,sizeof(num3));
}
return 0;
}
void A(char num[8])
{
char num1[8];
strcpy(num1,num);
num[3-1]=num1[2-1];
num[5-1]=num1[3-1];
num[4-1]=num1[5-1];
num[2-1]=num1[4-1];
}
void B(char num[8])
{
char num1[8];
strcpy(num1,num);
num[1-1]=num1[2-1];
num[5-1]=num1[1-1];
num[6-1]=num1[5-1];
num[2-1]=num1[6-1];
}
void C(char num[8])
{
char num1[8];
strcpy(num1,num);
num[4-1]=num1[6-1];
num[1-1]=num1[4-1];
num[3-1]=num1[1-1];
num[6-1]=num1[3-1];
}