Advertisement
Guest User

Untitled

a guest
Feb 14th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. bool wygranko(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.    
  38.    
  39.    
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46. bool pelna(int t[3][3]) {
  47.     for (int i=0; i<3; i++){
  48.         for (int j=0;j<3;j++){
  49.             if (t[i][j]==0){
  50.                 return false;
  51.             }
  52.         }
  53.     }
  54.    
  55.     return true;
  56. }
  57.  
  58.  
  59.  
  60.  
  61.  
  62. int suma (int t[3][3]){
  63.     int s=0;
  64.     for(int i=0;i<3;i++){
  65.         for(int j=0;j<3;j++){
  66.             s=s+t[i][j];
  67.            
  68.         }
  69.     }
  70.    
  71.     return s;
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.    
  85.    
  86. void wypisz(int t[3][3]){
  87.    
  88.     for(int i=0; i<3; i++){
  89.         for (int j=0;  j<3; j++){
  90.             if(t[i][j]==1){
  91.                 cout << "0";
  92.             }
  93.         else if (t[i][j]==2){
  94.             cout << "X";
  95.         }
  96.         else {
  97.             cout <<" ";}
  98.        
  99.         if (j<2){
  100.             cout <<"|";
  101.         }
  102.         }
  103.         cout << endl;
  104.         if (i<2){
  105.             cout << "-------" << endl;
  106.         }
  107.    
  108.    
  109.         }
  110.    
  111. }
  112.    
  113.  
  114.  
  115.  
  116.  
  117.  
  118. int main() {
  119.    
  120.     int t[3][3];
  121.     for(int a=0;a<3;a++){
  122.         for (int i=0;i<=2; i++){
  123.             cin >> t[a][i];
  124.         }
  125.     }
  126.    
  127.     wypisz(t);
  128.     cout << suma(t) << endl;
  129.    
  130.    
  131.     cout << pelna(t)<<endl;
  132.     cout << wygranko(t);
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement