ta ut max o mintal i java!!!|Programmering / Grafisk formgivning|Forum|Nordichardware

Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
The forums are currently locked and only available for read only access
sp_Feed sp_TopicIcon
ta ut max o mintal i java!!!
lurman
Siktar mot toppen
Medlem
Forum Posts: 72
Member Since:
August 31, 2001
sp_UserOfflineSmall Offline
1
May 13, 2002 - 12:19 pm
sp_Permalink sp_Print

jag har en sats som ser ut så här:
int[]tal = new int[20];

for(int i=0; i<=tal.length; i++)
{
int slump = (int)(Math.random()*20+1);
System.out.print(slump+",");
}

Hur tar jag ut maxtalet o mintalet av dessa 20 slumptal?

daggerr
Kommer du hit ofta?
Medlem
Forum Posts: 1367
Member Since:
August 7, 2001
sp_UserOfflineSmall Offline
169749
May 13, 2002 - 2:48 pm
sp_Permalink sp_Print

kan inte java men i c / c++ hade du gjort såhär:

int min,max;

min=max=tal[0] for(int a = 0 ; a < 20 ; a ++)
{
if(tal[a] min=tal[a];
if(tal[a]>max)
max=tal[a];
}
om det nu var det du ville veta.

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1030
Currently Online:
Guest(s) 275
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Andreas Galistel: 16287
Jonas Klar: 15897
ilg@dd: 10810
Nyhet: 10607
Mind: 10550
Ctrl: 10355
Gueno: 9881
Guest: 9344
Snorch: 8881
Callister: 8468
Newest Members:
PetrbonFU PetrbonFU
Karine Bembry
Dolores Mcdaniels
Anibal McLeish
Francisca Alt
Alfie Everhart
Lester Huitt
Orlando Jorgensen
Mikki Lundgren
Dakota Kozlowski
Forum Stats:
Groups: 11
Forums: 59
Topics: 146630
Posts: 1300967

 

Member Stats:
Guest Posters: 2
Members: 79425
Moderators: 0
Admins: 11
Administrators: nordicadmin, Henrik Berntsson, Anton Karmehed, Carl Holmberg, Joel Oscarsson, Mikael Linnér, Mikael Schwartz, Andreas Paulsson, Nickebjrk, Mattias Pettersson, EmxL