Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.29 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. bool CzyWygKol(int t[3][3]){
  8.    
  9.     for (int a=0; a<3; a++){
  10.      
  11.      if (t[a][0]*t[a][1]*t[a][2]==1){
  12.        
  13.         return true;
  14.          
  15.      }
  16.      
  17.        
  18.     }
  19.    
  20.     for (int j=0;j<3;j++){
  21.         if (t[0][j]*t[1][j]*t[2][j]==1){
  22.             return true;
  23.         }
  24.    
  25.        
  26.     }
  27.    
  28.     if (t[0][0]*t[1][1]*t[2][2]==1){
  29.         return true;
  30.        
  31.     }
  32.    
  33.    
  34.     if (t[2][0]*t[2][1]*t[2][2]==1){
  35.         return true;
  36.     }
  37.     return false;
  38.    
  39.    
  40. }
  41.  
  42.  
  43. bool CzyWygKrzy(int t[3][3]){
  44.    
  45.     for (int a=0; a<3; a++){
  46.      
  47.      if (t[a][0]*t[a][1]*t[a][2]==8){
  48.        
  49.         return true;
  50.          
  51.      }
  52.      
  53.        
  54.     }
  55.    
  56.     for (int j=0;j<3;j++){
  57.         if (t[0][j]*t[1][j]*t[2][j]==8){
  58.             return true;
  59.         }
  60.    
  61.        
  62.     }
  63.    
  64.     if (t[0][0]*t[1][1]*t[2][2]==8){
  65.         return true;
  66.        
  67.     }
  68.    
  69.    
  70.     if (t[2][0]*t[2][1]*t[2][2]==8){
  71.         return true;
  72.     }
  73.    
  74.     return false;
  75.    
  76. }
  77.  
  78.  
  79.  
  80.  
  81. bool pelna(int t[3][3]) {
  82.     for (int i=0; i<3; i++){
  83.         for (int j=0;j<3;j++){
  84.             if (t[i][j]==0){
  85.                 return false;
  86.             }
  87.         }
  88.     }
  89.    
  90.     return true;
  91. }
  92.  
  93.  
  94.  
  95.  
  96.  
  97. int suma (int t[3][3]){
  98.     int s=0;
  99.     for(int i=0;i<3;i++){
  100.         for(int j=0;j<3;j++){
  101.             s=s+t[i][j];
  102.            
  103.         }
  104.     }
  105.    
  106.     return s;
  107. }
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.    
  120.    
  121. void wypisz(int t[3][3]){
  122.    
  123.     for(int i=0; i<3; i++){
  124.         for (int j=0;  j<3; j++){
  125.             if(t[i][j]==1){
  126.                 cout << "0";
  127.             }
  128.         else if (t[i][j]==2){
  129.             cout << "X";
  130.         }
  131.         else {
  132.             cout <<" ";}
  133.        
  134.         if (j<2){
  135.             cout <<"|";
  136.         }
  137.         }
  138.         cout << endl;
  139.         if (i<2){
  140.             cout << "-------" << endl;
  141.         }
  142.    
  143.    
  144.         }
  145.    
  146. }
  147.    
  148.  
  149.  
  150.  
  151.  
  152.  
  153. int main() {
  154.    
  155.     int t[3][3];
  156.     for(int a=0;a<3;a++){
  157.         for (int i=0;i<=2; i++){
  158.             cin >> t[a][i];
  159.         }
  160.     }
  161.    
  162.     wypisz(t);
  163.    
  164.    if  (CzyWygKol(t) ==1)
  165.    cout << "Wygrało kółko" <<endl;
  166.    
  167.    if (CzyWygKrzy(t)==1)
  168.    cout <<"Wygrał krzyżyk";
  169.    
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement