ZOJ3322-Who is Older?

本文介绍了一个简单的程序设计案例,用于比较两个人的出生日期以确定谁更年长。通过解析输入的日期格式并进行逐级比较,该程序能够准确地判断出两个人中谁的年龄更大。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Who is Older?

Time Limit: 1 Second      Memory Limit: 32768 KB

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

3
1983 06 06 1984 05 02
1983 05 07 1980 02 29
1991 01 01 1991 01 01

Sample Output

javaman
cpcs
same

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


题意:告诉你两个人的出生日期,问两个人谁更大,一样则输出same


#include <iostream>
#include <cstdio>

using namespace std;

#define LL long long
const int INF=0x3f3f3f3f;
const int MAX=100009;

int y1,y2,d1,d2,r1,r2;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d %d %d %d",&y1,&d1,&r1,&y2,&d2,&r2);
        if(y1==y2&&d1==d2&&r1==r2) printf("same\n");
        else if(y1==y2)
        {
            if(d1==d2)
            {
                if(r1>r2) printf("cpcs\n");
                else printf("javaman\n");
            }
            else
            {
                if(d1>d2) printf("cpcs\n");
                else printf("javaman\n");
            }
        }
        else if(y1>y2) printf("cpcs\n");
        else printf("javaman\n");
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值