[html]代码库
package cp;
public class cptest {
public static void main(String agrs[])
{
//中奖号码
int redarr[]= {1257893};
int bluenum=7;
System.out.printf("the right num is:");
for(int i=0;i<7;i++)
{
System.out.printf(" "+redarr[i]);
}
System.out.println("-"+bluenum);
//判断是否中奖
//int a[]={1257893};
int a[]={1257893};
//显示数组中数字
System.out.printf("your num is:");
for(int i=0;i<=7;i++)
{
System.out.printf(" "+a[i]);
}
int p=0,q=0;
//两个数组进行比较
for(int s=0;s<7;s++)
{
for(int t=0;t<7;t++)
{
if(redarr[t]==a[s])
p++;
}
}
if(bluenum==a[7])
q=1;
else
q=0;
System.out.println("");
if(p==7&&q==1)
System.out.println("level 1");
else
{
if(p==7&&q==0)
System.out.println("level 2");
else
{
if(p==6&&q==1)
System.out.println("level 3");
else
{
if(p==6&&q==0||p==5&&q==1)
System.out.println("level 4");
else
{
if(p==5&&q==0||p==4&&q==1)
System.out.println("level 5");
else
{
if(p==4&&q==0||p==3&&q==1)
System.out.println("level 6");
else
{
if(p>=3&&q==1)
System.out.println("level 7");
else
System.out.println("It's a pity!");}}}}}
}
}