Hi, Guest
0 Members and 1 Guest are viewing this topic.
{ ======================Simple Menu====================== }Program B10;var A : array[1..10,1..10] of integer; n, m, i, j, met, s, x, y : integer; c: char;begin write('Numarul coloanelor si randurilor='); readln(n); for i:=1 to n do for j:=1 to n do readln(A[i,j]); for i:=1 to n do begin for j:=1 to n do write(A[i,j]:4); writeln; end; c:='D'; while upcase(c)='D' do begin writeln('Alegeti varianta de afisare:'); writeln('1 - Afisarea sumei tuturor elementelor'); writeln('2 - Afisarea elementelor pe diagonala principala'); writeln('3 - Afisarea elementelor pe diagonala secundara'); writeln('4 - Afisarea elementelor de sub diagonala secundara'); writeln('5 - Afisarea elementelor de sub diagonala principala si deasuprea diagonalei secundare'); writeln('6 - Afisarea busolei'); writeln('========================================================'); write('Metoda aleasa este '); readln(met); if met=1 then begin s:=0; for i:=1 to n do for j:=1 to n do s:=s+A[i,j]; writeln('========================================================'); writeln('Suma elementelor este ',s); end else if met=2 then begin writeln('========================================================'); writeln('Elementele de pe diagonala principala sunt:'); for i:=1 to n do write(A[i,i]:4); writeln; end else if met=3 then begin writeln('========================================================'); writeln('Elementele pe diagonala secundara sunt:'); for i:=1 to n do write(A[i,n+1-i]:4); writeln; end else if met=4 then begin writeln('========================================================'); writeln('Elementele de sub diagonala secundara sunt:'); for i:=1 to n do begin for j:=1 to n do begin if j>n+1-i then write(A[i,j]:3) else write(' ':3); end; writeln; end; end else if met=5 then begin writeln('========================================================'); writeln('Elementele de sub diagonala principala si deasupra diagonalei secundare sunt:'); for i:=1 to n do begin for j:=1 to n do begin if i>j then if j<n+1-i then write(A[i,j]:3) else write(' ':3); end; writeln; end; end else if met=6 then begin writeln('========================================================'); writeln('Busola, formata pe ',n,' coloane si pe ',n,' randuri:'); for i:=1 to n do begin for j:=1 to n do begin if i=j then write('0':3) else if j=n+1-i then write('0':3); if i<j then if i+j<n+1 then write('N':3); if i>j then if i+j>n+1 then write('S':3); if i>j then if i+j<n+1 then write('V':3); if i<j then if i+j>n+1 then write('E':3); end; writeln; end; end; writeln('========================================================'); write('Din nou?(D/N) : '); readln(c); writeln; end;end.
Sa inteleg ca-s singurul caruia ii place sa le numeasca Arrayuri 2D. Cod in python... blec.Asta e o chestie de baza, e nice. :]