-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlivecodingDateCount.cpp
More file actions
49 lines (41 loc) · 893 Bytes
/
livecodingDateCount.cpp
File metadata and controls
49 lines (41 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
using namespace std;
int isLeapYear(int year);
int operator1(int year,int month, int day);
int month1[] ={31,28,31,30,31,30,31,31,30,31,30,31};
int month2[] ={31,29,31,30,31,30,31,31,30,31,30,31};
int main(){
int t;
int year;
int month;
int day;
cin >> t;
for(int i=0; i<t; i++){
cin >> year >> month >>day;
cout<< operator1(year,month,day)<<endl;
}
return 0;
}
int isLeapYear(int year)
{
if((year%4==0) && (year%100 !=0) || (year%400 ==0)){
return 1;
}
else
return 0;
}
int operator1(int year, int month, int day){
int sum =0;
if (!isLeapYear(year)){
for(int j =0; j<month; j++){
sum += month1[j-1];
}
}
else{
for(int i =0; i<month; i++){
sum += month2[i-1];
}
}
// cout<<day<<endl;
return sum+day;
}