Keke

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Keke as PDF for free.

More details

  • Words: 261
  • Pages: 2
program bt_thongke_day_chanle; Uses crt; Var a:array[1..20] of integer; i,n,sc,sl:integer; tong:integer; Begin clrscr; write('n='); readln(n); writeln('Nhap cac phan tu:'); for i:=1 to n do begin write('Phan tu',i,'='); readln(a[i]); end; sc:=0; {so pt chan } sl:=0; {so pt le } tong:=0; for i:=1 to n do if a[i] mod 2 = 0 then sc:=sc+1 else begin sl:=sl+1; tong:=tong+a[i]; end; if sl>0 then writeln('Trung binh cong cac phan tu le cua day=',tong/sl:0:2) else writeln('Day khong co phan tu le'); Writeln('So phan tu chan cua day la:',sc); readln; End. program tinh_tong_cac_phan_tu_cua_ma_tran; var i,j,m,n:integer; a:array[1..20,1..20] of integer; S:integer; begin {nhap mang} writeln(' nhap cac gia tri m,n'); write('m='); readln(m); write('n='); readln(n); for i:=1 to m do for j:=1 to n do begin write('A[',i,',',j,']='); readln(A[i,j]); end; {ra mang} for i:=1 to m do begin for j:=1 to n do write(A[i,j]:4); writeln; end; {tinh tong cac phan tu} S:=0; for i:=1 to m do for j:=1 to n do S:=S+A[i,j]; write(S); writeln; readln; end.

program chen_mot_vecto_vao_hang_k_matran; var m,n,i,j,k:integer; A:array[1..101,1..100] of integer; B:array[1..100] of integer; begin writeln('vao gia tri m,n'); write('m=':2); readln(m); write('n=':2); readln(n); for i:=1 to m do for j:=1 to n do begin write('A[',i,',',j,']='); readln(A[i,j]); end; writeln('nhap vecto b'); for i:=1 to n do begin write('nhap B[',i,']='); readln(B[i]); end; write('nhap so k='); readln(k); if k>m then for j:=1 to n do A[m+1,j]:=B[j]; if k<=m then begin for i:= m+1 downto k+1 do for j:=1 to n do A[i,j]:=A[i-1,j]; for j:=1 to n do A[k,j]:=B[j]; end; writeln('ma tran A sau khi chen'); for i:=1 to m+1 do begin for j:=1 to n do write(A[i,j]:4); writeln; end; readln; end.

Related Documents