Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tab= zeros(3,3);
- % 1-zielony 2-czerwony 3-zolty 4 niebieski
- wej=rand(1,20).*4;
- wej=wej+1;
- wej=floor(wej);
- r=1;
- for i=3:-1:2
- for j=1:3
- tab(j,i)=wej(r);
- r=r+1;
- end
- end
- wyj=zeros(1,20);
- %tab(3,3)=0;
- tab
- w=0;
- wo=1;
- for x=1:3
- % if x==1
- % wyj=tab(1,3);
- % tab(1,3)=tab(1,2);
- % tab(1,2)=0;
- % end
- for i=1:3
- for j=3:-1:1
- if tab(j,i)==0
- tab(j,i)=wej(r);
- r=r+1;
- w=1;
- break
- end
- end
- if w==1
- break
- end
- end
- if(x==1)
- wyj(wo)=tab(3,3);
- wo=wo+1;
- tab(3,3)=tab(3,2);
- tab(3,2)=tab(3,1);
- tab(3,1)=0;
- continue
- end
- for i=1:3
- if tab(i,3)==wyj(wo)
- ;wyj(wo)=tab(i,3)
- wo=wo+1;
- tab(i,3)=tab(i,2);
- tab(i,2)=tab(i,1);
- tab(i,1)=0;
- break
- else
- wyj(wo)=tab(3,3);
- wo=wo+1;
- tab(3,3)=tab(3,2);
- tab(3,2)=tab(3,1);
- tab(3,1)=0;
- break
- end
- end
- end
- tab
- wyj
- wo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement