c語言輸入一個天數?
#include<stdio.h>
int main()
{
int i,n=0,year=0,month=0,day=0;
printf("請輸入天數<輸入-1退出測試>:");
scanf("%d",&n);
while(n!=-1)
{
while(n>=360)
{
n-=360;
year++;
}
while(n>=30)
{
n-=30;
month++;
}
while(n>0)
{
n--;
day++;
}
printf("%d年%d月%d日\n",year,month,day);
year=month=day=0;
printf("請輸入天數<輸入-1退出測試>:");
scanf("%d",&n);
}
return 0;
}