0
복권 프로그램을 만들어 0-9 사이에서 3 개의 숫자를 무작위로 생성 한 다음 무작위로 3 개의 우승 숫자를 생성했습니다. 프로그램이 승자를 표시하는 방법 (일부가있는 경우)을 만들고 복권 당첨자 수를 표시하는 방법에 대한 도움이 필요합니다.복권 당첨자 표시
는 는그래서 같은 : 당신은 루프에 대한 또 다른 원하는 여기에 2
내 프로그램
import java.util.Random;
public class TwoDArray
{
public static void main(String[] args)
{
int[][] table = new int[50][3];
int[][] win = new int[1][3];
Random rand = new Random();
int i = 1;
// Load the table with values
for (int row=0; row < table.length; row++)
for (int col=0; col < table[row].length; col++)
table[row][col] = rand.nextInt(7-0 +1)+0 + col;
// Load the winning Values
for (int row=0; row < win.length; row++)
for(int col=0; col < win[row].length; col++)
win[row][col] = rand.nextInt(7-0 +1)+0 + col;
// Print the table of People
for (int row=0; row < table.length; row++)
{
System.out.print("Person" + i++ +":\t");
for (int col=0; col < table[row].length; col++)
System.out.print(table[row][col] + "\t");
System.out.println();
}
//Print the Winning Numbers
for (int row=0; row < win.length; row++)
{
System.out.print("\nThe winning numbers are:\t");
for(int col=0; col < win[row].length; col++)
System.out.print(win[row][col] + "\t");
System.out.println();
}
}
}
rand.nextInt (7-0 일)의 rand.nextInt (8) 이상의 구문 다르지 않다 후자는 –