ZOJ-3322-Who is Older?【7th浙江省赛】

ZOJ-3322-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

题目链接:ZOJ-3322

题目大意: 给出两个人的出生日期,比较两个人的大小

题目思路:水题

以下是代码:

#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
int y[5],m[5],d[5];
int cmp()
{
    if (y[0] != y[1]) return y[0] < y[1];
    else if (m[0] != m[1]) return m[0] < m[1];
    else if (d[0] != d[1]) return d[0] < d[1];
    else return -1;
}
int main(){
    int t;
    cin >> t;
    while(t--)
    {   
        for (int i = 0; i < 2; i++) cin >> y[i] >> m[i] >> d[i];
        int ans = cmp(); 
        if (ans == -1) cout << "same\n";
        else if (ans == 0) cout << "cpcs\n";
        else cout << "javaman\n";
    } 
    return 0;
}

你可能感兴趣的:(ZOJ,3322)