Below is part of my program ... i did some modification so it will be easier to understand ... i tried to generate some random numbers for my card arrays but once i execute it ... the program seems to be STUCK ...
i use Microsoft Visual C++ 6.0 as compiler
the compiler detects no errors with my program ...
--------------------Configuration: Untitled1 - Win32 Debug--------------
Compiling...
Untitled1.cpp
Linking...
Untitled1.exe - 0 error(s), 0 warning(s)
anyone mind to explain to me why this happen ?Code:#include <iostream> #include <cstdlib> using namespace std; void gen(); void initial_card(); void initial_called(); int card[5][5][4]; int called[25]; int number; int x, y, z; int main() { initial_card(); initial_called(); cout << "Test" << endl; for(z=0; z<4; z+=2) { for(x=0; x<5; x++) { for(y=0; y<5; y++) { gen(); card[x][y][z]=number; card[x][y][z+1]=number; } } initial_called(); } cout << "Test Again !!" << endl; system("PAUSE"); return 0; } void gen() // something wrong here i think ... { do { number=(rand()%25)+1; if(called[number]==0) { called[number]=1; break; } }while(true); } void initial_card() { for(z=0; z<4; z++) { for(x=0; x<5; x++) { for(y=0; y<5; y++) card[x][y][z]=0; } } } void initial_called() { for(x=0; x<26; x++) called[x]=0; }



LinkBack URL
About LinkBacks



