Advertisement
linkedparadise

Bai tong hop 20-3-2017

Mar 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.84 KB | None | 0 0
  1. uses crt;
  2. var a:array[1..50,1..50] of integer;
  3.     r,c,i,j,tong1,tong2,dem1,dem2:integer;
  4.     tbc:real;
  5. begin
  6.     clrscr;
  7.     write('Nhap so dong, so cot: ');
  8.     readln(r,c);
  9.  
  10.     // Nhap mang
  11.     for i:=1 to r do
  12.         for j:=1 to c do
  13.             begin
  14.                 write('Nhap a[',i,',',j,']:' );
  15.                 readln(a[i,j]);
  16.             end;
  17.  
  18.     // Xuat mang
  19.     for i:=1 to r do
  20.         begin
  21.             for j:=1 to c do
  22.                 write(a[i,j]);
  23.             writeln;
  24.         end;
  25.  
  26.     // Tinh tong cac phan tu
  27.     tong1:=0;
  28.     for i:=1 to r do
  29.         for j:=1 to c do
  30.             tong1:=tong1+a[i,j];
  31.  
  32.     // Dem cac phan tu co gia tri chan
  33.     dem1:=0;
  34.     for i:=1 to r do
  35.         for j:=1 to c do
  36.             if (a[i,j] mod 2 = 0) then
  37.                 dem1:=dem1+1;
  38.  
  39.     // Tinh TBC cac phan tu co gia tri le
  40.     dem2:=0;
  41.     tong2:=0;
  42.     tbc:=0;
  43.     for i:=1 to r do
  44.         for j:=1 to c do
  45.             begin
  46.                 tong2:=tong2+a[i,j];
  47.                 dem2:=dem2+1;
  48.             end;
  49.     tbc:=tong2/dem2;
  50.  
  51. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement