Hello. My problem is like this. I have to make a program where i have 6 random number from 1 to 6. I can change any of the numbers 2 times. So far this is working for me. The next step i dont know how to begin. I have to remember what king of a resault my numbers have been. Like in a poker game. The 5 numbers represet cards. So now if i have two similar numbers, its one pair. Something like
25264 -> this is like one pair, i have to look for this and than print out like how many pairs, two pairs, tree of a kind and so on i had in one session of playing the game
I dont know how to do this. So far this is my code:
If you could just point me in the right direction.Code:#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int MetKocke(); int main(){ int Kocka[6]; int seme,ponovniMet,steviloKock,zamenjavaKock; char izhod='d'; seme=time(NULL); srand(seme); do{ for(int i=1;i<6;i++){ Kocka[i]=MetKocke(); cout<< "Kocka"<< i <<" = " << Kocka[i] << endl; } cout<<"Ponovni meti 0-krat, 1-krat, 2-krat? "; cin>>ponovniMet; for(int j=0;j<ponovniMet;j++){ cout<<"Koliko kock zelite ponovno metati od 1 do 5. "; cin>>steviloKock; for(int k=1;k<=steviloKock;k++){ cout<<"Katere kocke zelis zamenjat od 1 do 5 "; cin>>zamenjavaKock; Kocka[zamenjavaKock]=MetKocke(); for(int l=1;l<6;l++) cout<< "Kocka"<< l <<" = " << Kocka[l] << endl; } } cout<<"Go on with the game y ali n"<<" "; cin>>izhod; }while(izhod=='y'); return 0; } int MetKocke(){ return(rand()%6)+1; //random numbers from 1 to 6 }
Thank you in advance.
bnk



LinkBack URL
About LinkBacks



