Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream> //igra poker - pokušaj
- #include<cstdlib>
- #include<string>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand (time(0));
- int spil[52];
- int i, a, m;
- string vrstaime[4]={"Srca", "Pika", "Karoa", "Trefa"}; //vrsta karata
- string brojime[13]={" A", " 2", " 3", " 4", " 5"," 6"," 7"," 8"," 9"," 10"," J"," Q"," K"}; //broj karata
- cout<<" "<<endl;
- cout<<" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
- cout<<" $$$ $$$$$ $$$$ $$$$$ $$ $$$ $$$$$"<<endl;
- cout<<" $$$ $$$$$ $$$ $$$$$ $$$ $$$$ $$$ $$$$$$$$ $$$$$ $$$$"<<endl;
- cout<<" $$$ $$$$$ $$$ $$$$$ $$$ $$$ $$$$ $$$$$$$$ $$$$$ $$$$"<<endl;
- cout<<" $$$ $$$$ $$$$$ $$$ $$ $$$$$ $$$$$$$$ $$$$$"<<endl;
- cout<<" $$$ $$$$$$$$$ $$$$$ $$$ $$$$$$ $$$ $$$$$$$$$"<<endl;
- cout<<" $$$ $$$$$$$$$ $$$$$ $$$ $$ $$$$$ $$$$$$$$ $ $$$$$$$$"<<endl;
- cout<<" $$$ $$$$$$$$$ $$$$$ $$$ $$$ $$$$ $$$$$$$$ $$ $$$$$$$"<<endl;
- cout<<" $$$ $$$$$$$$$ $$$$$ $$$ $$$$ $$$ $$$$$$$$ $$$$ $$$$$"<<endl;
- cout<<" $$$ $$$$$$$$$$ $$$$ $$$$$ $$ $$$ $$$$$ $$$$"<<endl;
- cout<<" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"<<endl;
- while (a<1 || a>2) {
- cout<<" Odaberite da li zelite sami unijeti vrijednost karata ili ce karte biti"<<endl;
- cout<<" nasumicno izgenerirane( 1=Sami unesite 2=Nasumicno regeneriranje):";
- cin>>a;
- cout<<endl;
- }
- for (i=0; i<52; i++) //napravljeni novi spil
- {
- spil[i]=i;
- }
- for (i=0; i<52; i++) //promijesane karte i napravljeni novi promjesan spil
- {
- int j=rand()%52;
- int temp=spil[i];
- spil[i]=spil[j];
- spil[j]=temp;
- }
- for (i=0; i<52; i++) //promjesan spil i ispisane karte
- {
- int vrstabroj = spil[i]/13;
- int brojk = spil[i]%13;
- }
- int R[5]; //dobivanje broja karata
- int S[5]; //dobivanje boje karata
- //korisnik odabire mogucnost vlastitog unosa karata
- if (a == 1)
- {
- cout<<"Vrijednosti karata su sljedece:A=0"<<endl;
- cout<<" 2=1"<<endl;
- cout<<" 3=2"<<endl;
- cout<<" 4=3"<<endl;
- cout<<" 5=4"<<endl;
- cout<<" 6=5"<<endl;
- cout<<" 7=6"<<endl;
- cout<<" 8=7"<<endl;
- cout<<" 9=8"<<endl;
- cout<<" 10=9"<<endl;
- cout<<" J=10"<<endl;
- cout<<" Q=11"<<endl;
- cout<<" K=12"<<endl;
- cout<<""<<endl;
- while (R[0]<0 || R[0]>13) {
- cout<<" Unesite vrijednost prve karte:";
- cin>> R[0];
- }
- while (R[1]<0 || R[1]>13) {
- cout<<" Unesite vrijednost druge karte:";
- cin>> R[1];
- }
- while (R[2]<0 || R[2]>13) {
- cout<<" Unesite vrijednost trece karte:";
- cin>> R[2];
- }
- while (R[3]<0 || R[3]>13) {
- cout<<" Unesite vrijednost cetvrte karte:";
- cin>> R[3];
- }
- while (R[4]<0 || R[4]>13) {
- cout<<" Unesite vrijednost pete karte:";
- cin>> R[4];
- cout<<""<<endl;
- }
- cout<<"Vrijednosti boja su sljedece:Srce=0"<<endl;
- cout<<" Pik=1"<<endl;
- cout<<" Karo=2"<<endl;
- cout<<" Tref=3"<<endl;
- cout<<""<<endl;
- while (S[0]<0 || S[0]>3) {
- cout<<" Unesite boju prve karte:";
- cin>> S[0];
- }
- while (S[1]<0 || S[1]>3) {
- cout<<" Unesite boju druge karte:";
- cin>> S[1];
- }
- while (S[2]<0 || S[2]>3) {
- cout<<" Unesite boju trece karte:";
- cin>> S[2];
- }
- while (S[3]<0 || S[3]>3) {
- cout<<" Unesite boju cetvrte karte:";
- cin>> S[3];
- }
- while (S[4]<0 || S[4]>3) {
- cout<<" Unesite boju pete karte:";
- cin>> S[4];
- }
- cout<<""<<endl;
- }
- else
- for (i=0; i<5; i++)
- {
- R[i] = spil[i]%13;
- S[i] = spil[i]/13;
- }
- bool swapped = false;
- do
- {
- //prolaz kroz bubble petlju
- swapped = false;
- for(int i=0; i<4; i++)
- {
- if(R[i] > R[i+1])
- {
- int temp = R[i];
- R[i] = R[i+1];
- R[i+1] = temp;
- swapped = true;
- }
- }
- }
- while(swapped == true);
- for (i=0; i<5; i++) //ispisivanje prvih 5 dobivenih karata
- {
- cout<<brojime[R[i]] << " od " << vrstaime[S[i]] <<endl;
- }
- cout<<endl;
- //ispitivanje Royal Flush-a
- if((R[0] == 0 && R[1] == 9 && R[2] == 10 && R[3] == 11 && R[4] == 12 ) &&
- (S[0] == S[1] && S[2]==S[3] && S[0]==S[4]))
- {
- cout<<"Dobili ste Royal Flush!"<<endl;
- }
- else
- //ispitivanje Skale u boji
- if((R[1]==R[0]+1 && R[2]==R[1]+1 && R[3]==R[2]+1 && R[4]==R[3]+1) && (S[0] == S[1] && S[2]==S[3] && S[4]==S[0]))
- {
- cout<<"Dobili ste Skalu u Boji!"<<endl;
- }
- else
- //ispitivanje Cetri iste
- if((R[0] == R[1] && R[2] == R[3] && R[0] == R[3]) ||
- (R[0] == R[1] && R[2] == R[4] && R[0] == R[4]) ||
- (R[0] == R[2] && R[3] == R[4] && R[0] == R[3]) ||
- (R[1] == R[2] && R[3] == R[4] && R[1] == R[4]))
- {
- cout<<"Dobili ste Cetiri Iste!"<<endl;
- }
- else
- //ispitivanje Full House
- if((R[0] == R[1] && R[2] == R[3] && R[3] == R[4]) ||
- (R[0] == R[2] && R[3] == R[4] && R[4] == R[1]) ||
- (R[0] == R[3] && R[1] == R[2] && R[2] == R[4]) ||
- (R[0] == R[4] && R[1] == R[2] && R[2] == R[3]) ||
- (R[1] == R[2] && R[0] == R[4] && R[4] == R[3]) ||
- (R[1] == R[3] && R[2] == R[4] && R[4] == R[0]) ||
- (R[1] == R[4] && R[0] == R[3] && R[3] == R[2]) ||
- (R[2] == R[3] && R[4] == R[1] && R[4] == R[0]) ||
- (R[3] == R[4] && R[1] == R[2] && R[2] == R[0]) ||
- (R[2] == R[4] && R[3] == R[1] && R[1] == R[0]))
- {
- cout<<"Dobili ste Full House!"<<endl;
- }
- else
- //ispitivanje Boje
- if(S[0] == S[1] && S[2]==S[3] && S[4]==S[0])
- {
- cout<<"Dobili ste Boju!"<<endl;
- }
- else
- //ispititvanje Skale
- if ((R[0] == 0 && R[1] == 9 && R[2] == 10 && R[3] == 11 && R[4] == 12 ) ||
- (R[1]==0 && R[2]==R[1]+1 && R[3]==R[2]+1 && R[4]==R[3]+1))
- {
- cout<<"Dobili ste Skalu!"<<endl;
- }
- else
- //ispitivanje Trisa
- if(R[0] == R[1] && R[1] == R[2] || R[1] == R[2] && R[2] == R[3] || R[2] == R[3] && R[3]== R[4])
- {
- cout<<"Dobili ste Tris!"<<endl;
- }
- else
- //ispitivanje Dva Para
- if((R[0] == R[1] && R[2] == R[3]) || (R[1] == R[2] && R[3] == R[4]) || (R[0] == R[1] && R[3] == R[4]))
- {
- cout<<"Dobili ste Dva Para!"<<endl;
- }
- else
- //ispitivanje Para
- if(R[0] == R[1] || R[1] == R[2] || R[2] == R[3] || R[3] == R[4])
- {
- cout<<"Dobili ste Par!"<<endl;
- }
- else
- //ispis
- cout<<"Niste dobili nista!"<<endl;
- cout<<endl;
- cout<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement