Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdlib.h>
- using namespace std;
- test(int mesto[9]){
- if(mesto[1]==1&&mesto[2]==1&&mesto[3]==1) return 1;
- else if(mesto[4]==1&&mesto[5]==1&&mesto[6]==1) return 1;
- else if(mesto[7]==1&&mesto[8]==1&&mesto[9]==1) return 1;
- else if(mesto[1]==1&&mesto[4]==1&&mesto[7]==1) return 1;
- else if(mesto[2]==1&&mesto[5]==1&&mesto[8]==1) return 1;
- else if(mesto[3]==1&&mesto[6]==1&&mesto[9]==1) return 1;
- else if(mesto[1]==1&&mesto[5]==1&&mesto[9]==1) return 1;
- else if(mesto[3]==1&&mesto[5]==1&&mesto[7]==1) return 1;
- else if(mesto[1]==0&&mesto[2]==0&&mesto[3]==0) return 2;
- else if(mesto[4]==0&&mesto[5]==0&&mesto[6]==0) return 2;
- else if(mesto[7]==0&&mesto[8]==0&&mesto[9]==0) return 2;
- else if(mesto[1]==0&&mesto[4]==0&&mesto[7]==0) return 2;
- else if(mesto[2]==0&&mesto[5]==0&&mesto[8]==0) return 2;
- else if(mesto[3]==0&&mesto[6]==0&&mesto[9]==0) return 2;
- else if(mesto[1]==0&&mesto[5]==0&&mesto[9]==0) return 2;
- else if(mesto[3]==0&&mesto[5]==0&&mesto[7]==0) return 2;
- }
- ispisivanje(int mesto[10]) {
- cout<<endl<<" | | "<<endl;
- cout<<" "<<mesto[1]<<" | "<<mesto[2]<<" | "<<mesto[3]<<endl;
- cout<<"___|___|___"<<endl;
- cout<<" | | "<<endl;
- cout<<" "<<mesto[4]<<" | "<<mesto[5]<<" | "<<mesto[6]<<endl;
- cout<<"___|___|___"<<endl;
- cout<<" | | "<<endl;
- cout<<" "<<mesto[7]<<" | "<<mesto[8]<<" | "<<mesto[9]<<endl;
- cout<<" | | "<<endl<<endl;
- }
- int main(){
- int n;
- int mesto[10];
- for(int i=1;i<10;i++) mesto[i]=i;
- ispisivanje(mesto);
- for(int i=1;i<10;i++){
- if(i%2==0) {
- cout<<"Red je na drugog igraca,unesite broj:";
- cin>>n;
- mesto[n]=0;
- system("cls");
- cout<<n<<endl;
- ispisivanje(mesto);
- }
- else{
- cout<<"Red je na prvog igraca,unesite broj:";
- cin>>n;
- mesto[n]=1;
- system("cls");
- cout<<n<<endl;
- ispisivanje(mesto);
- }
- if(test(mesto)==1){
- cout<<"Pobednik je 1. igrac";
- break;
- }
- else if(test(mesto)==2){
- cout<<"Pobednik je 2. igrac";
- break;
- }
- else continue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement