void main()
{
int a[]={1,2,3,4,5,6,7}
int b[7],i,j,count=0,max=0,maxflag
for(i=0i<7i++)
scanf("%d",&b[i])
i=0
while(i<7)
{
j=0
count=0
if(b[i]==a[j])
while(i<7 && j<7 && b[i]==a[j]) i++,j++,count++
else
i++
if(max<count) {max =countmaxflag=i}
}
count = max
if(count==7) printf("特等奖\n")
else if(count==6)
{
if(maxflag==7)
printf("二等奖\n")
else
printf("一等奖\n")
}
else if(count==5)
{
if(maxflag==7)
printf("三等奖\n")
else
printf("二等奖\n")
}
else if(count==4)
{
if(maxflag==7)
printf("四等奖\n")
else
printf("三等奖\n")
}
else if(count==3)
{
if(maxflag==7)
printf("五等奖\n")
else
printf("四等奖\n")
}
else if(count==2 && maxflag!=7)
printf("五等奖\n")
else
printf("没中奖\n")
}
import java.util.ArrayListimport java.util.Collections
import java.util.List
import java.util.Random
public class Main {
public static void main(String[] args) {
//红球 33 选6
List<Integer> redBall = new ArrayList<Integer>()
for(int i=0i<33i++){
redBall.add(i+1)
}
System.out.println("开奖红球:" + select(redBall, 6))
//篮球16选1
List<Integer> blueBall = new ArrayList<Integer>()
for(int i=0i<16i++){
blueBall.add(i+1)
}
System.out.println("开奖蓝球:" + select(blueBall, 1))
}
public static List<Integer> select(List<Integer> list,int count){
List<Integer> selectedList = new ArrayList<Integer>()
Random random = new Random()
for(int i=0i<counti++){
int index = random.nextInt(list.size())
Integer number = list.get(index)
selectedList.add(number)
list.remove(index)
}
Collections.sort(selectedList)
return selectedList
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)