#1904: I will give you the answer but one chicken cover(雞包)


1753980-3@g.puiching.edu.mo (P5A31蒲雋浠)

School : No School
ID : 2571
IP address : [192.168.120.33]
Last Login :
2025-03-20 12:13:05
a040. 文文的求婚 (三) -- 板橋高中教學題 | From: [192.168.120.33] | Post Date : 2025-04-08 20:14

#include <iostream>
using namespace std;

bool isLeapYear(int year) {
    if (year % 4 != 0) {
        return false;
    } else if (year % 100 != 0) {
        return true;
    } else if (year % 400 == 0) {
        return true;
    } else {
        return false;
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    
    int count = 0;
    for (int year = a; year <= b; year++) {
        if (isLeapYear(year)) {
            count++;
        }
    }
    
    cout << count << endl;
    return 0;
}
 
#1911: Re:I will give you the answer but one chicken cover(雞包)


1755143-9@g.puiching.edu.mo (zero3)

School : Pui Ching Middle School
ID : 3019
IP address : [192.168.120.33]
Last Login :
2025-04-07 21:37:43
a040. 文文的求婚 (三) -- 板橋高中教學題 | From: [192.168.120.33] | Post Date : 2025-04-09 20:32

#include 
using namespace std;

bool isLeapYear(int year) {
    if (year % 4 != 0) {
        return false;
    } else if (year % 100 != 0) {
        return true;
    } else if (year % 400 == 0) {
        return true;
    } else {
        return false;
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    
    int count = 0;
    for (int year = a; year <= b; year++) {
        if (isLeapYear(year)) {
            count++;
        }
    }
    
    cout << count << endl;
    return 0;
}


So easy La don't need to post

 
ZeroJudge Forum