Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdlib.h>
  3. using namespace std;
  4. test(int mesto[9]){
  5. if(mesto[1]==1&&mesto[2]==1&&mesto[3]==1) return 1;
  6. else if(mesto[4]==1&&mesto[5]==1&&mesto[6]==1) return 1;
  7. else if(mesto[7]==1&&mesto[8]==1&&mesto[9]==1) return 1;
  8. else if(mesto[1]==1&&mesto[4]==1&&mesto[7]==1) return 1;
  9. else if(mesto[2]==1&&mesto[5]==1&&mesto[8]==1) return 1;
  10. else if(mesto[3]==1&&mesto[6]==1&&mesto[9]==1) return 1;
  11. else if(mesto[1]==1&&mesto[5]==1&&mesto[9]==1) return 1;
  12. else if(mesto[3]==1&&mesto[5]==1&&mesto[7]==1) return 1;
  13. else if(mesto[1]==0&&mesto[2]==0&&mesto[3]==0) return 2;
  14. else if(mesto[4]==0&&mesto[5]==0&&mesto[6]==0) return 2;
  15. else if(mesto[7]==0&&mesto[8]==0&&mesto[9]==0) return 2;
  16. else if(mesto[1]==0&&mesto[4]==0&&mesto[7]==0) return 2;
  17. else if(mesto[2]==0&&mesto[5]==0&&mesto[8]==0) return 2;
  18. else if(mesto[3]==0&&mesto[6]==0&&mesto[9]==0) return 2;
  19. else if(mesto[1]==0&&mesto[5]==0&&mesto[9]==0) return 2;
  20. else if(mesto[3]==0&&mesto[5]==0&&mesto[7]==0) return 2;
  21. }
  22. ispisivanje(int mesto[10]) {
  23.  
  24. cout<<endl<<" | | "<<endl;
  25. cout<<" "<<mesto[1]<<" | "<<mesto[2]<<" | "<<mesto[3]<<endl;
  26. cout<<"___|___|___"<<endl;
  27. cout<<" | | "<<endl;
  28. cout<<" "<<mesto[4]<<" | "<<mesto[5]<<" | "<<mesto[6]<<endl;
  29. cout<<"___|___|___"<<endl;
  30. cout<<" | | "<<endl;
  31. cout<<" "<<mesto[7]<<" | "<<mesto[8]<<" | "<<mesto[9]<<endl;
  32. cout<<" | | "<<endl<<endl;
  33.  
  34. }
  35. int main(){
  36. int n;
  37. int mesto[10];
  38. for(int i=1;i<10;i++) mesto[i]=i;
  39. ispisivanje(mesto);
  40.  
  41. for(int i=1;i<10;i++){
  42. if(i%2==0) {
  43. cout<<"Red je na drugog igraca,unesite broj:";
  44. cin>>n;
  45. mesto[n]=0;
  46. system("cls");
  47. cout<<n<<endl;
  48. ispisivanje(mesto);
  49. }
  50. else{
  51. cout<<"Red je na prvog igraca,unesite broj:";
  52. cin>>n;
  53. mesto[n]=1;
  54. system("cls");
  55. cout<<n<<endl;
  56. ispisivanje(mesto);
  57. }
  58. if(test(mesto)==1){
  59. cout<<"Pobednik je 1. igrac";
  60. break;
  61. }
  62. else if(test(mesto)==2){
  63. cout<<"Pobednik je 2. igrac";
  64. break;
  65. }
  66. else continue;
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement