Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1.    
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <cstdlib>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. int main(){
  10.     int r;
  11.     int x,y;
  12.     int tab[9][9];
  13.     srand(time(NULL));
  14.     void wyczysc();
  15.     int licznik,l2=0;      
  16.     int i;
  17.     int xz,yz;
  18.     for(y=1;y<10;y++){
  19.         for(x=1;x<10;x++){
  20.                 tab[y-1][x-1]=rand()%9+1;
  21.                 i=0;
  22.                 if(x+y!=2)
  23.                
  24.                 for(int a=2;a<10;a++){
  25.                             if(x-a>=0){
  26.                                 if(tab[y-1][x-1]==tab[y-1][x-a]){x--;licznik++;i=1;
  27.                                 }
  28.                             }
  29.                             if(y-a>=0){
  30.                                 if(tab[y-1][x-1]==tab[y-a][x-1]){x--;licznik++;i=1;
  31.                                 }
  32.                             }
  33.                        
  34.                            
  35.            
  36.                         }
  37.                         if(y%3!=1){
  38.                                 yz=(y-1)%3;
  39.                                 xz=(x-1)%3;
  40.                                 for(int c=1;c<3;c++){
  41.                                    
  42.                                    
  43.                                        
  44.                                         if(yz-c>=0){
  45.                                             if(xz==0){
  46.                                                
  47.                                                 if(tab[y-1][x-1]==tab[y-c-1][x]){x--;licznik++;i=1;}
  48.                                                 if(tab[y-1][x-1]==tab[y-c-1][x+1]){x--;licznik++;i=1;}
  49.                                             }
  50.                                             if(xz==1){
  51.                                                 if(tab[y-1][x-1]==tab[y-c-1][x-2]){x--;licznik++;i=1;}
  52.                                                 if(tab[y-1][x-1]==tab[y-c-1][x]){x--;licznik++;i=1;}
  53.                                             }
  54.                                             if(xz==2){
  55.                                                 if(tab[y-1][x-1]==tab[y-c-1][x-2]){x--;licznik++;i=1;}
  56.                                                 if(tab[y-1][x-1]==tab[y-c-1][x-3]){x--;licznik++;i=1;}
  57.                                             }
  58.                                         }
  59.                                    
  60.                                 }  
  61.                             }
  62.                                 if(licznik==100){cout<<"q";x=0;l2++;}
  63.                 if(l2==100){cout<<"!";x=0;y=1;l2=0;}
  64.                
  65.                 if(i==0)licznik=0;
  66.            
  67.         }
  68.        
  69.     cout<<endl;
  70.    
  71.     }
  72.     for(y=1;y<10;y++){
  73.         if(y==1)cout<<" - - - - - - - - - - - -"<<endl;
  74.         for(x=1;x<10;x++){
  75.             if(x==1)cout<<"|";
  76.                 cout<<" "<<tab[y-1][x-1];
  77.                 if(x%3==0)cout<<" |";
  78.             }
  79.            
  80.         cout<<endl;
  81.         if(y%3==0)cout<<" - - - - - - - - - - - -"<<endl;  
  82.         }
  83.        
  84.    
  85.  
  86.     return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement