有代码不懂,望大佬进来看看!
#include <iostream>using namespace std;
int main()
{
const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31};
int index;
for (index = 0; index < sizeof days / sizeof days[0]; index++)
cout << "Month " << index + 1 << " has " << days[index] << " days.\n";
cout << endl;
return 0;
}
这一段不懂
for (index = 0; index < sizeof days / sizeof days[0]; index++)
有大神可以解释一下吗??
然后输出为什么是
Month 1 has 31 days.
Month 2 has 28 days.
Month 3 has 31 days.
Month 4 has 30 days.
Month 5 has 31 days.
Month 6 has 30 days.
Month 7 has 31 days.
Month 8 has 31 days.
Month 9 has 30 days.
Month 10 has 31 days.
Month 2 has 28 days.
Month 3 has 31 days.
Month 4 has 30 days.
Month 5 has 31 days.
Month 6 has 30 days.
Month 7 has 31 days.
Month 8 has 31 days.
Month 9 has 30 days.
Month 10 has 31 days.
谢谢大神指导!!