HDU-6213-Chinese Zodiac(水题)

来源:互联网 发布:如何开通淘宝视频直播 编辑:程序博客网 时间:2024/05/21 11:05

Problem Description
The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle related to an animal sign. These signs are the rat, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, rooster, dog and pig.
Victoria is married to a younger man, but no one knows the real age difference between the couple. The good news is that she told us their Chinese Zodiac signs. Their years of birth in luner calendar is not the same. Here we can guess a very rough estimate of the minimum age difference between them.
If, for instance, the signs of Victoria and her husband are ox and rabbit respectively, the estimate should be2 years. But if the signs of the couple is the same, the answer should be 12 years.
 

Input
The first line of input contains an integer T (1T1000) indicating the number of test cases.
For each test case a line of two strings describes the signs of Victoria and her husband.
 

Output
For each test case output an integer in a line.
 

Sample Input
3ox roosterrooster oxdragon dragon
 

Sample Output
8412

题意:妹子和一个比她年轻的人结婚了,给你他们两个人的生肖,让你求他们两个人最小的年龄差,注意下妹子比她丈夫大就行了,水题。
思路:随便写。
代码:
#include<iostream>  #include<cstdio>  #include<cstring>  #include<string.h>  #include<stdio.h>  using namespace std;  int main()      {      char x[12][10]={"rat","ox","tiger","rabbit","dragon","snake","horse","sheep","monkey","rooster","dog","pig"};      char a[10],b[10];      int i,s1,s2,t;      cin>>t;      while(t--)          {          cin>>a>>b;          if(strcmp(a,b)==0)              {              cout<<12<<endl;              continue;              }          for(i=0;i<12;i++)              {              if(strcmp(a,x[i])==0)                  s1=i;              if(strcmp(b,x[i])==0)                  s2=i;              }          if(s1<s2)              cout<<(s1-s2)*-1<<endl;          else              cout<<12-s1+s2<<endl;          }      return 0;      }  
总结:水题。





原创粉丝点击