
用delphi7 输入年月 判断:是否闰年? 这个月有几天? 这个月的季节? 哪里错了?请大侠指教并改正。谢谢
programProject2;{$APPTYPECONSOLE}usesSysUtils;varx,y:integer;beginwrite('请输入年x:');rea...
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
x,y:integer;
begin
write('请输入年x:');
readln(x);
write('请输入月y:') ;
readln(y);
if (x mod 4 =0 ) and (x mod 100 <>0 ) or (x mod 400 = 0) then
writeln('这一年是闰年');
case y of
1,3,5,7,8,10,12:writeln('该月有31天');
4,6,9,11:writeln('该月有30天') ;
2:writeln('该月有29天') ;
case y of
3,4,5:writeln('该月为春季');
6,7,8:writeln('该月为夏季');
9,10,11:writeln('该月为秋季');
12,1,2 :writeln('该月为冬季') ;
else
writeln('这一年是平年');
begin
case y of
1,3,5,7,8,10,12:writeln('该月有31天') ;
4,6,9,11:writeln('该月有30天') ;
2:writeln('该月有28天');
end;
case y of
3,4,5:writeln('该月为春季') ;
6,7,8:writeln('该月为夏季') ;
9,10,11:writeln('该月为秋季') ;
12,1,2 :writeln('该月为冬季') ;
end;
{ TODO -oUser -cConsole Main : Insert code here }
end. 展开
{$APPTYPE CONSOLE}
uses
SysUtils;
var
x,y:integer;
begin
write('请输入年x:');
readln(x);
write('请输入月y:') ;
readln(y);
if (x mod 4 =0 ) and (x mod 100 <>0 ) or (x mod 400 = 0) then
writeln('这一年是闰年');
case y of
1,3,5,7,8,10,12:writeln('该月有31天');
4,6,9,11:writeln('该月有30天') ;
2:writeln('该月有29天') ;
case y of
3,4,5:writeln('该月为春季');
6,7,8:writeln('该月为夏季');
9,10,11:writeln('该月为秋季');
12,1,2 :writeln('该月为冬季') ;
else
writeln('这一年是平年');
begin
case y of
1,3,5,7,8,10,12:writeln('该月有31天') ;
4,6,9,11:writeln('该月有30天') ;
2:writeln('该月有28天');
end;
case y of
3,4,5:writeln('该月为春季') ;
6,7,8:writeln('该月为夏季') ;
9,10,11:writeln('该月为秋季') ;
12,1,2 :writeln('该月为冬季') ;
end;
{ TODO -oUser -cConsole Main : Insert code here }
end. 展开
1个回答
展开全部
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
x,y:integer;
begin
write('请输入年x:');
readln(x);
write('请输入月y:') ;
readln(y);
if (x mod 4 =0 ) and (x mod 100 <>0 ) or (x mod 400 = 0) then
begin
writeln('这一年是闰年');
case y of
1,3,5,7,8,10,12:writeln('该月有31天');
4,6,9,11:writeln('该月有30天') ;
2:writeln('该月有29天') ;
end;
case y of
3,4,5:writeln('该月为春季');
6,7,8:writeln('该月为夏季');
9,10,11:writeln('该月为秋季');
12,1,2 :writeln('该月为冬季') ;
end;
end
else
begin
writeln('这一年是平年');
case y of
1,3,5,7,8,10,12:writeln('该月有31天') ;
4,6,9,11:writeln('该月有30天') ;
2:writeln('该月有28天');
end;
case y of
3,4,5:writeln('该月为春季') ;
6,7,8:writeln('该月为夏季') ;
9,10,11:writeln('该月为秋季') ;
12,1,2 :writeln('该月为冬季') ;
end;
end;
readln;
{ TODO -oUser -cConsole Main : Insert code here }
end.
{$APPTYPE CONSOLE}
uses
SysUtils;
var
x,y:integer;
begin
write('请输入年x:');
readln(x);
write('请输入月y:') ;
readln(y);
if (x mod 4 =0 ) and (x mod 100 <>0 ) or (x mod 400 = 0) then
begin
writeln('这一年是闰年');
case y of
1,3,5,7,8,10,12:writeln('该月有31天');
4,6,9,11:writeln('该月有30天') ;
2:writeln('该月有29天') ;
end;
case y of
3,4,5:writeln('该月为春季');
6,7,8:writeln('该月为夏季');
9,10,11:writeln('该月为秋季');
12,1,2 :writeln('该月为冬季') ;
end;
end
else
begin
writeln('这一年是平年');
case y of
1,3,5,7,8,10,12:writeln('该月有31天') ;
4,6,9,11:writeln('该月有30天') ;
2:writeln('该月有28天');
end;
case y of
3,4,5:writeln('该月为春季') ;
6,7,8:writeln('该月为夏季') ;
9,10,11:writeln('该月为秋季') ;
12,1,2 :writeln('该月为冬季') ;
end;
end;
readln;
{ TODO -oUser -cConsole Main : Insert code here }
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询