练习使用数组
#include<stdio.h>
int main ()
{
int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int month;
for(month=1;month<=12;month++)
printf("month %d has %d days.\n",month,days[12]);
}
运行效果
month 1 has 0 days.
month 2 has 0 days.
month 3 has 0 days.
month 4 has 0 days.
month 5 has 0 days.
month 6 has 0 days.
month 7 has 0 days.
month 8 has 0 days.
month 9 has 0 days.
month 10 has 0 days.
month 11 has 0 days.
month 12 has 0 days.