if(i=j)then StringGrid2.Cells[j-1,i-1]:=IntToStr(mas2[i]) else StringGrid2.Cells[j-1,i-1]:=IntToStr(mas2[i,j]);