ZOJ 3322 Who is Older?.

来源:互联网 发布:thinking in java在线 编辑:程序博客网 时间:2024/05/16 01:34

Javaman and cpcs are arguing who is older. Write a program to help them.

Input

There are multiple test cases. The first line of input is an integer T (0 < T <= 1000) indicating the number of test cases. Then T test cases follow. The i-th line of the next T lines contains two dates, the birthday of javaman and the birthday of cpcs. The format of the date is "yyyy mm dd". You may assume the birthdays are both valid.

Output

For each test case, output who is older in a single line. If they have the same birthday, output "same" (without quotes) instead.

Sample Input

31983 06 06 1984 05 021983 05 07 1980 02 291991 01 01 1991 01 01

Sample Output

javamancpcssame

Author: CAO, Peng
Source: The 7th Zhejiang Provincial Collegiate Programming Contest
====

一道水题,不知不觉涨了好多姿势。
判断时间,日期这种题,直接用字符串比较就行了。
#include<stdio.h>#include<string.h>int main(){    int t;    scanf("%d\n",&t);   //注意\n    while(t--)    {        char s[30];        gets(s);        s[10]=0;    //== s[10]='\0';        int ok=strcmp(s,s+11);  //注意strcmp函数,遇到'\0'直接结束比较。        if(ok>0)            puts("cpcs");        else if(ok<0)            puts("javaman");        else            puts("same");    }    return 0;}


0 0