Page 141 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 141

100 Problems & Solutions                                               Trang 141


                      var j     :integer;
                       begin
                         for j:=dong[i-1]+1 to N-5+i do
                           begin
                             dong[i]:=j;
                             if i=5 then kiemtra
                              else thu(i+1);
                             if ok=false then exit;
                           end;
                       end;
                      procedure lam;
                      var i,j,x,y,u,v,k :integer;
                       begin
                         for i:=1 to dem do
                           for j:=dem downto 1 do
                            for x:=1 to dem do
                             for y:=dem downto 1 do
                               begin
                                  for u:=1 to 5 do
                                   for v:=1 to 5 do a[u,v]:=w[i,u,v];
                                  for u:=1 to 5 do
                                   for v:=1 to 5 do a[u,5+v]:=w[j,u,v];
                                  for u:=1 to 5 do
                                   for v:=1 to 5 do a[5+u,v]:=w[x,u,v];
                                  for u:=1 to 5 do
                                   for v:=1 to 5 do a[5+u,5+v]:=w[y,u,v];

                                  fillchar(c,sizeof(c),0);
                                  fillchar(ddd,sizeof(ddd),0);
                                  fillchar(dong,sizeof(dong),0);
                                  for u:=1 to N do
                                   for v:=1 to N do
                                     begin
                                       inc(c[v],a[u,v]);
                                       inc(ddd[u],a[u,v]);
                                     end;
                                  ok:=true;
                                  for k:=1 to N do
                                   if (c[k]=0)or(ddd[k]=0) then ok:=false;
                                  if ok then thu(1);
                                  if ok then
                                   begin
                                     inc(sl);
                                     writeln('*******:',sl,':*******');
                                     writeln(f,'*******:',sl,':*******');
                                     for u:=1 to N do
                                        begin
                                           for v:=1 to N do
                                             begin
                                               write(a[u,v],#32);



                      Tin học & Nhà trường                                       100 Đề Toán - Tin học
   136   137   138   139   140   141   142   143   144   145   146