私は学校のためのプロジェクトに取り組んでおり、これを理解することはできません。私は非常に初心者の初心者です。6の整数の配列を2次元のint配列[19] [5]とどのように比較できますか?
私はtickets[19][6]
と呼ばれる2つの配列を各チケットに6つのintを付けています。 私はこれらの20のチケットを、.txtファイルから読み取ったwinner[5]
という6つの数字を持つ通常の整数配列に比較しようとしています。
次のように両方のアレイが記載されている:
public static int[] winner = new int[5]
public static int[][] tickets = new int[19][5]
私はこれまで非常に新たなんだ、と私は事前に任意の助けに感謝覚えておいてください!
EDITこれは私の2次元配列にユーザー入力を割り当てるために使用しているループです。これは無限ループだったことをすべて知りました。私はコードを書いているのはもっと....と思っていました。これまでのデバッグの技術に似ているようだ。
static void ticketNumberArray(){
int number = 1; // which of the six numbers you need from the ticket
int ticketCount = 1; // which ticket (out of 20) you are currently on
while(ticketCount<21){ // sentinel controlled while loop,
// will continue until the twentieth ticket is entered
System.out.println("Please type number " +number+ " of ticket number " +ticketCount+ ".");
//asks for the numbers of the ticket your currently on
Scanner keyboard = new Scanner(System.in); // initiates a scanner variable
int ticketNumber = keyboard.nextInt(); // assigns user input to the double variable ticketNumber
// and initializes as a double
tickets[ticketCount-1][number-1]=ticketNumber; // assigns user input into a 2-d array
number++; //Sentinel variable
if(number==7){ //loop that controls the ticket count, every 6 numbers ='s one ticket
ticketCount++;
number=1;
}
}
}
「比較する」とはどういう意味ですか?平等のためのテスト? –
私は平等のためのテストははいと信じています。私は勝者[]をチケット[] []と比較してチケット[] []を検索して勝者と一致させようとしています[] – BBradshaw1
"iteration" - 'for 'ループ、例えば。おそらく3つのネストされたループ。 (おそらく、おそらく2つのループ、入れ子になって、あなたの問題を再読み込みします。) –