BUPTOJ 0087-0089

来源:互联网 发布:ubuntu cuda caffe 编辑:程序博客网 时间:2024/06/02 23:27

这三道略水,做得很顺利。

BUPTOJ 0087日期

/*USER_ID: test#aa3615058PROBLEM: 87SUBMISSION_TIME: 2014-03-19 21:08:42*/#include <iostream>#include <stdio.h>using namespace std; bool isLeapYear(int year); int main() {    int days[12] = {0,31,59,90,120,151,181,212,243,273,304,334};     int y,m,d;    int caseCount = 0;    cin >> caseCount;    for(int i = 0; i < caseCount; i++) {        scanf("%d:%d:%d", &y, &m, &d);        if(m > 2 && isLeapYear(y)) {            cout << (days[m-1]+d+1) << endl;        } else {            cout << (days[m-1]+d) << endl;        }    }     return 0;} bool isLeapYear(int year) {    if(year % 100 == 0) {        if(year % 400 == 0) {            return true;        } else {            return false;        }    } else if(year % 4 == 0) {        return true;    } else {        return false;    }}

BUPTOJ 0088最值问题

/*USER_ID: test#aa3615058PROBLEM: 88SUBMISSION_TIME: 2014-03-19 21:35:37*/#include <iostream>using namespace std; int main() {     int caseCount;    cin >> caseCount;    for(int i = 0; i < caseCount; i++) {        int numberCount;        cin >> numberCount;        int max = 0;        int secmax = 0;        int temp;        int s[numberCount];        for(int j = 0; j < numberCount; j++) {            cin >> s[j];            temp = s[j];            if(temp > max) {                max = temp;            }        }        for(int j = 0; j < numberCount; j++) {            temp = s[j];                if(temp > secmax && temp < max) {                    secmax = temp;                }        }        cout << max << " " << secmax << endl;    }     return 0;}

BUPTOJ 0089统计时间间隔

/*USER_ID: test#aa3615058PROBLEM: 89SUBMISSION_TIME: 2014-03-19 22:13:18*/#include <stdio.h> int main() {    int n;    while(scanf("%d", &n) != EOF) {        int h1, h2, m1, m2;        for(int i = 0; i < n; i++) {            scanf("%d:%d", &h1, &m1);            scanf("%d:%d", &h2, &m2);            h1 = h2 - h1;            m1 = m2 - m1;             if(h1 < 0 || (h1 == 0 && m1 < 0)) {                h1 += 24;            }            m1 += h1*60;            printf("%d\n", m1);        }    }     return 0;}


0 0
原创粉丝点击