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

100 Problems & Solutions                                               Trang 106


                      write('nhap n>=2:');readln(n);
                      for i:=1 to n do
                       for j:=1 to n do
                        begin
                            write('nhap a[',i,'j]:');
                            readln(a[i,j]);
                        end;
                      end;
                      {----------------------}
                      procedure tinh;
                      begin
                      clrscr;
                      nhap;
                      s:=0;
                      for i:=1 to n-1 do
                       for j:=1 to n-1 do
                        if ((a[i,j]<a[i,j+1])and(a[i,j+1]<a[i+1,j+1])and(a[i+1,j+1]<a[i+1,j]))
                          or((a[i,j+1]<a[i+1,j+1])and(a[i+1,j+1]<a[i+1,j])and(a[i+1,j]<a[i,j]))
                          or((a[i+1,j+1]<a[i+1,j])and(a[i+1,j]<a[i,j])and(a[i,j]<a[i,j+1]))
                          or((a[i+1,j]<a[i,j])and(a[i,j]<a[i,j+1])and(a[i,j+1]<a[i+1,j+1]))
                             then inc(s);
                      writeln;
                      writeln;
                      writeln;
                      writeln('So luong tu giac dong ho la:',s);
                      readln;
                      end;
                      {-----------------}
                      procedure max;
                      var t:integer;
                      begin
                      writeln('Nhap n>=2:');readln(n);
                      i:=1;
                      a1:=1;a2:=n;
                      b1:=1;b2:=n;
                      mau:=0;
                      t:=0;
                      while i<=n*n do
                       begin
                         for k:=a1 to a2 do
                          begin
                             a[b1,k]:=i;
                             gotoxy(5*k,b1);
                             inc(mau);
                             if mau>15 then mau:=1;
                             textcolor(mau);
                             write(i);
                             delay(70);inc(i);
                          end;
                         for k:=b1+1 to b2+t do



                      Tin học & Nhà trường                                       100 Đề Toán - Tin học
   101   102   103   104   105   106   107   108   109   110   111