Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main(){
- int r;
- int x,y;
- int tab[9][9];
- srand(time(NULL));
- void wyczysc();
- int licznik,l2=0;
- int i;
- int xz,yz;
- for(y=1;y<10;y++){
- for(x=1;x<10;x++){
- tab[y-1][x-1]=rand()%9+1;
- i=0;
- if(x+y!=2)
- for(int a=2;a<10;a++){
- if(x-a>=0){
- if(tab[y-1][x-1]==tab[y-1][x-a]){x--;licznik++;i=1;
- }
- }
- if(y-a>=0){
- if(tab[y-1][x-1]==tab[y-a][x-1]){x--;licznik++;i=1;
- }
- }
- }
- if(y%3!=1){
- yz=(y-1)%3;
- xz=(x-1)%3;
- for(int c=1;c<3;c++){
- if(yz-c>=0){
- if(xz==0){
- if(tab[y-1][x-1]==tab[y-c-1][x]){x--;licznik++;i=1;}
- if(tab[y-1][x-1]==tab[y-c-1][x+1]){x--;licznik++;i=1;}
- }
- if(xz==1){
- if(tab[y-1][x-1]==tab[y-c-1][x-2]){x--;licznik++;i=1;}
- if(tab[y-1][x-1]==tab[y-c-1][x]){x--;licznik++;i=1;}
- }
- if(xz==2){
- if(tab[y-1][x-1]==tab[y-c-1][x-2]){x--;licznik++;i=1;}
- if(tab[y-1][x-1]==tab[y-c-1][x-3]){x--;licznik++;i=1;}
- }
- }
- }
- }
- if(licznik==100){cout<<"q";x=0;l2++;}
- if(l2==100){cout<<"!";x=0;y=1;l2=0;}
- if(i==0)licznik=0;
- }
- cout<<endl;
- }
- for(y=1;y<10;y++){
- if(y==1)cout<<" - - - - - - - - - - - -"<<endl;
- for(x=1;x<10;x++){
- if(x==1)cout<<"|";
- cout<<" "<<tab[y-1][x-1];
- if(x%3==0)cout<<" |";
- }
- cout<<endl;
- if(y%3==0)cout<<" - - - - - - - - - - - -"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement