java面向对象程序设计问题
- 提问者网友:欲望失宠
- 2021-04-14 02:46
- 五星知识达人网友:孤独入客枕
- 2021-04-14 02:53
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner (System.in);
int shu[]=new int[7];
for(int i =0;i<shu.length;i++)
{
shu[i]=(int)(Math.random()*10);
}
int inp[]=new int [7];
System.out.println ("输入0~9的数:");
for(int i=0;i<inp.length;i++)
{
System.out.print("输入第"+(i+1)+"个数:");
inp[i]=input.nextInt();
}
int num=0;
for(int i=0;i<shu.length;i++)
{
if (shu[i]==inp[i])
{
num++;
}
}
System.out.println ("中奖号码是:");
for(int i=0;i<shu.length;i++)
{
System.out.print(shu[i]+" ");
}
System.out.println ();
if(num==2)
{
System.out.println ("六等奖");
}else if (num==3)
{
System.out.println ("五等奖");
}else if (num==4)
{
System.out.println ("四等奖");
}else if (num==5)
{
System.out.println ("三等奖");
}else if (num==6)
{
System.out.println ("二等奖");
}else if (num==7)
{
System.out.println ("一等奖");
}else
{
System.out.println ("没中奖");
}
}
应该能用的
- 1楼网友:撞了怀
- 2021-04-14 03:22