#include <iostream> using namespace std; int main() { int a, b[a], c; cin >> a; for (c=0;c<a;c++) { cin >> b[a]; if ((b[a]>0)&&(b[a]%4==0)&&(b[a]%100!=0)) { cout << "a leap year" << endl; } else if ((b[a]>0)&&(b[a]%400==0)&&(b[a]%3200!=0)) { cout << "a leap year" << endl; } else { cout << "a normal year" << endl; } } }
#include using namespace std; int main() { int a, b[a], c; cin >> a; for (c=0;c<a;c++) { cin >> b[a]; if ((b[a]>0)&&(b[a]%4==0)&&(b[a]%100!=0)) { cout << "a leap year" << endl; } else if ((b[a]>0)&&(b[a]%400==0)/*&&(b[a]%3200!=0*/)) { cout << "a leap year" << endl; } else { cout << "a normal year" << endl; } } }
不用這一行,這不是標準的求閏年,要依題目的規定。
#include using namespace std; int main() { int a, b[a], c; cin >> a; for (c=0;c<a;c++) { cin >> b[a]; if ((b[a]>0)&&(b[a]%4==0)&&(b[a]%100!=0)) { cout << "a leap year" << endl; } else if ((b[a]>0)&&(b[a]%400==0)/*&&(b[a]%3200!=0*/)) { cout << "a leap year" << endl; } else { cout << "a normal year" << endl; } } }
不用這一行,這不是標準的求閏年,要依題目的規定。
還有,你的b[a]其實可以改成b就好,就可以少36kb的記憶體。XD