nascar Posted June 29, 2011 Report Share Posted June 29, 2011 Sveiki! Tātad, man min skaitlis ir 1 max ir 30, un tad sāk pieteikšanos lietotāji piemēram: Māris 4 Kaspars 22 mana doma ir tā, ka piesakās viņam izkrit skaitlis kuru auto izvelas sistema no 1 > 30 Paldies. :) Quote Link to comment Share on other sites More sharing options...
rebuilder Posted June 29, 2011 Report Share Posted June 29, 2011 rand() Ja vispār uztvēru Tavu domu... Quote Link to comment Share on other sites More sharing options...
nascar Posted June 29, 2011 Author Report Share Posted June 29, 2011 (edited) hmm tā škiet ka ir, paldies:) japameģina iekļaut skriptā. ==== UPDATED: Kā panākt, lai veicot rand() vins vienu skaitli neaktarto 2 reizes? Edited June 29, 2011 by nascar Quote Link to comment Share on other sites More sharing options...
Rincewind Posted June 30, 2011 Report Share Posted June 30, 2011 ==== UPDATED: Kā panākt, lai veicot rand() vins vienu skaitli neaktarto 2 reizes? Nekā, rand() tam nav paredzēts. Bet var uztaisīt random masīvu. $random = range(1, 30); shuffle($random); print_r($random); Quote Link to comment Share on other sites More sharing options...
nascar Posted June 30, 2011 Author Report Share Posted June 30, 2011 (edited) mmmm, nu gan ir īstais :) paldies Rincewind! == Emm, man šitas šteles nav stipra puse, kā panākt lai katru reizi spiezot REFRESH pogu, butu tikai viens skaitlis piemeram vienreiz 4 20 1 apmeram tā, proti man to vajg sutit uz tabulu un pa 10 skaitliem nevar sutit, vajg vienu. Palides! Edited June 30, 2011 by nascar Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted June 30, 2011 Report Share Posted June 30, 2011 Un kas notiks pēc 30 reizes? Quote Link to comment Share on other sites More sharing options...
nascar Posted June 30, 2011 Author Report Share Posted June 30, 2011 nu tur būs man sava sistēma, kas automatiski aizstaisa... vienkārši es šito nezinu, kas un kā! Kāds var man iedot kodu, jo es tiešam nezinu... proti pateikšu velreiz, man vajg sūtit vienu skaitli uz DB tabulu, kas no 1 lidz 30 neatkārtojas skaitlis un + lai tas skaitlis būtu viens, nevis visi 30 rinda. Cerams ka sapratāt, ši nav mana stipra puse. Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted June 30, 2011 Report Share Posted June 30, 2011 Dari to ko Rincewind teica un beigās pielieto array_pop lai dabūtu tikai vienu skaitli. Tad to masīvu saglabā kaut kur (db, fails, ...) un nākamreiz izmanto tikai array_pop lai atkal dabūtu nākamo skaitli un beigās atkal saglabā. Kad masīv būs tukšs tad arī varēsi darīt ko nu vajag darīt. Quote Link to comment Share on other sites More sharing options...
nascar Posted June 30, 2011 Author Report Share Posted June 30, 2011 es šādi izdariju, $numbers = range(1,30); shuffle($numbers); echo array_pop($numbers); jā tagad izvelk vienu skaitli, bet cik maniju atkārtojās. Esmu tā nedaudz apjucis, tu man vari uzrakstit koda piemēru lūdzu. Quote Link to comment Share on other sites More sharing options...
Kemito Posted June 30, 2011 Report Share Posted June 30, 2011 "Tu vari man uztaisīta koda piemēru" - Uz Darba sadaļu Betmenu, un maku vaļā. Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted June 30, 2011 Report Share Posted June 30, 2011 (edited) - Uz Darba sadaļu Betmenu, un maku vaļā. vai uz manuāli, jo tur piemēru daudz. Edited June 30, 2011 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
mixis Posted June 30, 2011 Report Share Posted June 30, 2011 jā tagad izvelk vienu skaitli, bet cik maniju atkārtojās. Ja negribi, lai atkārtojas, pieglabā kaut kur jau izmantotos skaitļu un pie katras nākamās skirpta palaišana reizes tos izņem no pieejamo skaitļu masīva. Quote Link to comment Share on other sites More sharing options...
nascar Posted June 30, 2011 Author Report Share Posted June 30, 2011 Es visādi mēģinu, nesanāk. :[ Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted June 30, 2011 Report Share Posted June 30, 2011 Paraadi ko tu meegjini. Quote Link to comment Share on other sites More sharing options...
nascar Posted June 30, 2011 Author Report Share Posted June 30, 2011 (edited) $izvelk = 2; // no $i atņemam -1 - izvelk 1 ciparu $cipari = range(1, 30); $auto_choise = array_rand($cipari,$izvelk); shuffle($auto_choise); for($i=1; $i<$izvelk; $i++) { echo $auto_choise[$i]; } Saku uzreiz, šita štelle man ir gruti saprotama. Edited June 30, 2011 by nascar Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.