Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by nati ( 6 years ago )
#include <iostream>
#include<time.h>
#include<stdio.h>
#include<cstdlib>
#include<conio.h>
using namespace std;
int main()
{
string symbol[3]= {"kamien", "papier", "nozyce"};
int choice;
srand(time(0));
cout << "Witaj w grze kamien, papier, nozyce! " << endl;
cout<< "Przed toba 10 rund gry, zycze powodzenia!"<<endl;
int play=1;
int punkty=0;
while(play<=10)
{
play++;
cout<< "\nWybierz bron: \n0-kamien \n1-papier \n2-nozyce"<<endl;
cin>> choice;
if(!(cin>>choice))
{
cerr<< "To nie jest cyfra!";
cin.clear();
cin.sync();
exit(0);
}
else
{
switch(choice)
{ case 0:
cout<< "Twoj wybor: " <<symbol[0];
break;
case 1:
cout<< "Twoj wybor: "<<symbol[1];
break;
case 2:
cout<< "Twoj wybor:"<< symbol[2];
break;
default:
cout<< "Nie ma takiej opcji gosciu";
break;
}
}
int x=(rand()%2);
if(choice==0 ||choice==1||choice==2)
{
cout<< "\n"<< "Komputer: "<< symbol[x] <<endl;
}
else
{
exit(0);
}
if(symbol[choice]==symbol[x])
{
cout<< "\nMamy remis!"<<endl;
}
if(choice==1 && x==0 || choice==0 && x==2 || choice==2 && x==1)
{
cout<< "Brawo wygrales!!!"<<endl;
punkty++;
}
if (choice==0 && x==1 || choice==1 && x==2 || choice==2 && x==0)
{
cout<< "\nPorazka!!!"<<endl;
}
}
cout<< "Gratulacje zdobyles/las "<< punkty<< " punktow na 10"<<endl;
getchar();
return 0;
}
Revise this Paste