基本的には、ユーザーから6つの入力番号を受け取り、配列に格納し、そのモードを計算するプログラムです。シングルモードの値はどのように取得できますか?
package p18;
import java.util.Scanner;
public class P18 {
public static void main(String[] args) {
Scanner S=new Scanner(System.in);
int[] arr1=new int [6];
for (int i = 0; i < 6; ++i) {
int g = S.nextInt();
arr1[i] = g;
}
int input=6;
for(int i=0;i<input;i++)
int count=0;
for(int j=0;j<input;j++)
{
int temp=arr1[j];
int tempco=0;
for(int p=0;p<input;p++)
if(arr1[p].equals[temp])
tempco++;
if(tempco>count)
{
int t=temp;
count=tempco;
}}
System.out.println("the most frequent number"+t+, +count);
}}
まず、適切な質問とあなたのコードを書式設定し、インデントを使用して将来的に役立つでしょう。第二に、あなたの問題は何か、そして可能な限り明確です。 –
私の問題はモードを計算することだけです –
Kruti Patel何について答えますか? –