这三道略水,做得很顺利。
BUPTOJ 0087日期
/*
USER_ID: test#aa3615058
PROBLEM: 87
SUBMISSION_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#aa3615058
PROBLEM: 88
SUBMISSION_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#aa3615058
PROBLEM: 89
SUBMISSION_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;
}