请问变量day怎么赋初值啊?

#include<stdio.h>
void main()
{unsigned int year,leap;<br>printf("enter year:");<br>scanf("%d",&year);<br>if(year%400==0)<br>leap=1;<br>else<br>{if (year%4==0&&year%100!=0)<br>leap=1;<br>else leap=0;<br>}
if(leap==1)printf("%d:is a leap year.",year);
else printf("%d is not a leap year.",year);
unsigned int month,day;
printf("enter month:");
scanf("%d",&month);
printf("%d\n",day);
} 1 warning(s) warning C4700: local variable 'month' used without having been initialized 

潇湘沐
浏览 98回答 2
2回答

ibeautiful

.#include <stdio.h>int leapYear(int year) // 判断是否为润年{if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)return 1;elsereturn 0;}void main(){int year, month;int m[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};printf ("请输入日期(格式:年 月):");scanf ("%d%d", &year, &month);if (leapYear(year)) m[1] += 1;printf ("%d年%d月共有%d天\n", year, month, m[month - 1]);}

慕森卡

#include<iostream>using namespace std;int isLeap(int year){if( year%400 == 0 || (year %4 == 0 && year %100 !=0)){return 1;}else{return 0;}}int main(){int year;int month;int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};cout<<"please input the year"<<endl;cin>>year;cout<<"please input the month"<<endl;cin>>month;if(isLeap(year)){a[1] = a[1] +1;}cout<<"days = "<<a[month-1]<<endl;cin.get();cin.get();return 0;}
打开App,查看更多内容
随时随地看视频慕课网APP