# Finding a certain random value in which row and how many times has been appeared

1 vue (au cours des 30 derniers jours)
N/A le 3 Jan 2023
Rouvert : N/A le 3 Jan 2023
Hello there we have a semester exercise in java and i would like a help, we want a program that stores a table of 20 random integer values and then asks the user to give a value from 0 to 20 and then to show if that value is among them how many times has appeared and in which positions
import java.io.*;
import java.util.Random;
class anazitisi // research
{
public static void main(String[]args) throws IOException
{
int[] x = new int;
Random rndm = new Random();
int i= rndm.nextInt();
for( i=0; i<20; i++)
x[i] = rndm.nextInt(20);
for( i=0; i<20; i++)
System.out.println("x["+i+"]="+x[i]);
System.out.println("Δώσε έναν αριθμό απο το 1 μέχρι το 20"); // give a value from 1 until 20
int b = Integer.parseInt(AR1);
System.out.println("O αριθμός" +x.length+ "βρέθηκε φορές στις θέσεις "); // the number....has been found x time in the positions.....
}
it's in greek but i hope you get the gist somehow any help please until 10/1 would be welcome i know it's very limited time ...Thanks in advance
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

KALYAN ACHARJYA le 3 Jan 2023
This is a Matlab forum, Matlab answer, try to replicate in other langauges-
rand_data=randi([0 20],[1, 20])
num=input('Enter any number (0 to 20): ')
times_num=sum(rand_data==num)
[r c]=find(rand_data==num)
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Logical dans Help Center et File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!