dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

problema
Goto page Previous  1, 2, 3
 
dev.gamez.lv Forum Index -> Programmēšana
View previous topic :: View next topic  
Author Message
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Mon Aug 07, 2006 7:57 pm    Post subject:

Droši vien pointerim name neesi izdalījis atmiņu.
char* name = new char[100]; // max 99 simboli
...
// vēlāk beigās:
delete [] name;

Protams, daudz prātīgāk būtu lietot:
char name[100];

Vai vēl prātīgāk - std::string un iostream/fstream bibliotēku.
Back to top
View user's profile Send e-mail
Lāčblēdis



Joined: 16 Jan 2005
Posts: 113

PostPosted: Mon Aug 07, 2006 8:42 pm    Post subject:

Bija jāraksta:
fscanf (fails, "%s\n%i", name, &time);
Back to top
View user's profile
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Mon Aug 07, 2006 9:12 pm    Post subject:

Arī :)
Back to top
View user's profile Send e-mail
coderpp



Joined: 20 Aug 2005
Posts: 167
Location: Rīga, Koknese, Gajiena

PostPosted: Sat Sep 02, 2006 9:52 am    Post subject:

Es ar rand() izveelos skaitli no 30. Kaa lai uztaisa to ka vinsh katru skaitli izveelas tikai vienreiz?
Back to top
View user's profile Send e-mail
tres^
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 03 Jul 2006
Posts: 16

PostPosted: Sat Sep 02, 2006 11:06 am    Post subject:

Izmanto masīvu. Aizpildi to ar cipariem no 1(0) līdz 30. Es sapratu tev vajag tādu intervālu. Tad samaisi to ar randomu, te ir piemērs http://www.fredosaurus.com/notes-cpp/misc/random-shuffle.html .

To while ciklu piemērā ar (cin << n) izmet un tev jau ir teju gatavs kods.
_________________
šmaraksts
Back to top
View user's profile
elvman
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 09 Apr 2003
Posts: 1278
Location: Kuldiga

PostPosted: Sat Sep 02, 2006 11:07 am    Post subject:

Es to droshi vien dariitu taa-njemu bool masiivu:
bool bUsed[30];
Tikliidz kaa panjem kaadu skaitli,taa atiieciigais elements masiivaair true(protams saakumaa vajag ZeroMemory'ot masiivu,lai visi elementi buutu false);Un ja izkriit skaitlis,kursh jau ir izmantots,tad rand()'ojam taalaak.
_________________
long time; /* know C */
Back to top
View user's profile Visit poster's website
elvman
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 09 Apr 2003
Posts: 1278
Location: Kuldiga

PostPosted: Sat Sep 02, 2006 11:10 am    Post subject:

Jap-mans piemeers ir diezgan nenoteikts.
tres^: labs piemeers.Atceros,kaa kaadreiz tieshi taisiju kaarshu speeles,tad arii mainiju elementus vienu ar otru.Principaa tev Albert sho piemeeru arii jaizmanto.
_________________
long time; /* know C */
Back to top
View user's profile Visit poster's website
Display posts from previous:   
dev.gamez.lv Forum Index -> Programmēšana All times are GMT + 2 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group