第1题:
下列程序要求用户输入一个年份,并能够判断用户输入的年份是否是闰年,横线处应填 Sub EnSure() Dim year As Integer Year=Val(InputBox("请输入年份:")) If(year Mod 4=0_____yaer Mod 100<>0)______(yaer Mod 400=0)Then Print"您输入的是闰年" Else Print"不是闰年,是普通年份" End If End SubA.And And B.And Or C.Or Or D.Or Or
第2题:
给定年份,下列程序用来判断该年是否为闰年,请填空。
提示:闰年的条件是年份可以被4整除但不能被100整除,或者能被400整除。
Private Sub Comand6_Click()
Dim y As Integer
y=InputBox("请输入年份")
If(y Mod 4=0______y Mod 100<>0)or(y Mod 400=0)Then
Print"是闰年"
Else
Print"是普通年份"
End If
End Sub
第3题:
请在每条横线处填写一个语句,使程序的功能为:判断输入的年份是否为闰年(例如:1998年不是闰年,2000年是闰年).
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。
import java.io.*;
public class LeapYear{
public static void main(String args[]){
___________________;
BufferedReader in;
ir=new InputStreamReader(_____________________________);
in=new BufferedReader(ir);
System. out. print In("输入年份是: ");
String s=in.readline();
int year=___________________
if(year%4==0&&year%100!=0||year%400==0
System.out.println(" "+year+" "年是闰年. ");
else
System.out.println(" " +year+ " "年不是闰年.");
}
}
}
第4题:
输出1900~2000年中所有的闰年。每输出3个年号换一行。(判断闰年的条件为下面二者之一:能被4整除,但不能被100整除。或者能被400整除。)
第5题:
下面程序是判断某一个是否为闰年,请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。(闰年的条件是符合下面两者之一:①能被4整除,但不能被100整除;②能被4整除,又能被100整除)。
注意:不改动程序的结构,不得增行或删行。
import java.io.*;
public class LeapYear
{
public static void main(String args[])
{
int year=1979;
if((year %4= =0 || year % 100 !=0) || (year % 400= =0))
System.out.println(year+"是闰年.");
else
System.out.println(year+"不是闰年。");
year=2000;
boolean leap;
if(year % 4 !=0)
leap=false;
else if(year % 100 !=0)
leap=true;
else if(year % 400 !=0)
leap=false;
else
leap=true;
if(______)
System.out.println(year+"是闰年。");
else
System.out.println(year+"不是闰年。");
year=2010;
if(year % 4= =0)
{
if(year % 100= =0)
{
if(year % 400= =0)
leap=true;
else
______
}
else
leap=false;
}
if(1eap= =true);
System.out.println(year+"是闰年。");
else
System.out.println(year+"不是闰年。");
}
}
第6题:
请补充fun函数,该函数的功能是:判断一个年份是否为闰年。
例如,1900年不是闰年,2004是闰年。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
[试题源程序]
include<stdio.h>
include<conio.h>
int fun(int n)
{
int fiag=0;
if(n%4==0)
{
if( (1) )
fiag=1;
}
if( (2) )flag=1;
return (3) ;
}
void main()
{
int year;
clrscr();
printf("Input the year:");
scanf("%d", &year);
if(fun(year))
printf("%d is a leap year.\n", year);
else
printf("%d is not a leap year.\n", year);
}
第7题:
请完成下列Java程序:输出某年的某月有多少天数,要求生成2个输入对话框,一个输入年份,一个输入月份,并且能检查输入的数字是否符合要求,如果符合要求,则根据输入的年份和月份计算出这一年的这一月有多少天。提示:闰年为年数能被4整除但是不能被100整除。
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
程序运行结果如下:
import javax.swing. JOptionPane;
public class ex10_2 {
public static void main(String[] args) (
String strIn;
int nYear,nMonth,nNumOfDays=0;
strIn=JOptionPane.showInputDialog(,,year.);
nYear=Integer.parseInt(strIn);
if(nYear<0) {
System.out.println("Invalidate number of year!")
return;
} strIn=JOptionPane.showInputDialog("month.);
nMonth=Integer.parseInt(strIn);
if(_____________) {
System.out.println("Invalidate number of month!"
return;
}
switch(nMonth){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
nNumOfDays=31;
break;
case 4:
case 6:
case 9:
case 11:
nNumOfDays=30;
break;
case 2:
if(________________)
nNumOfDays=29;
else
nNumOfDays=28;
break;
}
System.out.println("Number of days:"+ nNumOfDays);
}
}
第8题:
能被2整除的数叫做( ),不能被2整除的数叫做( )。
第9题:
下列程序要求用户输入一个年份,并能够判断用户输入的年份是否是闰年,下划线处应填( )。 Sub EnSure() Dim year As Integer year=Val(InputBox("请输入年份:")) If(year Mod 4=0 ______ year Mod 100<>0) ______ (year Mod 400=0) Then Print "您输入的是闰年" Else Print "不是闰年,是普通年份" End If End Sub
A.And And
B.And Or
C.Or Or
D.Or Or
第10题:
下列程序要求用户输入一个年份,并能够判断用户输入的年份是否是闰年,横线处应填( )。
Sub EnSure()
Dim year As Integer
year=Val(InputBox("请输入年份:"))
If(year Mod 4=0______year Mod 100<>0)______(year Mod 400=0)Then
Print"您输入的是闰年"
Else
Print"不是闰年,是普通年份"
End If
End Sub
A.And And
B.And Or
C.Or Or
D.Or Of