我是這樣寫的,哪里錯了?為什么不行?
#include"stdio.h"
main()
{
int a,count;
a=1,count=0;
while(a<2017)
{
if(a%4==0&&a%100!=0||a%400==0)
count++;
else a++;
}
printf("%d\t\n,%d",a,count);
}
1 回答

望遠
TA貢獻1017條經(jīng)驗 獲得超1032個贊
#include"stdio.h" ?main()?{? ?int?a,count;?a=1,count=0; ?while(a<2017)? ?{? ?if(a%4==0&&a%100!=0||a%400==0)//是閏年 ?{ ?count++; ?printf("%10d",a);//輸出一個閏年數(shù)據(jù) ?if(count%5==0)//每5個數(shù)據(jù)換行 ?printf("\n"); ?} ?a++;?//無論a是多少,它都有加1 }? ?printf("\n"); ?printf("一共%d個年份\n",count);//最后輸出有多少個數(shù)據(jù) ?}
- 1 回答
- 0 關(guān)注
- 3061 瀏覽
添加回答
舉報
0/150
提交
取消