Tin học Cho dãy số thực a1, a2, … an. (1 24/07/2021 By Quinn Cho dãy số thực a1, a2, … an. (1 { "@context": "https://schema.org", "@type": "QAPage", "mainEntity": { "@type": "Question", "name": " Cho dãy số thực a1, a2, … an. (1
uses crt; var n,i:byte; a:array[0..100] of real; tb,min:real;BEGIN clrscr; write(‘Nhap so phan tu:’); readln(n); tb:=0; for i:=1 to n do begin write(‘Nhap a[‘,i,’]:’); readln(a[i]); tb:=tb+a[i]; end; tb:=tb/n; min:=abs(a[1]-tb); for i:=2 to n do if abs(a[i]-tb)<min then min:=abs(a[i]-tb); for i:=1 to n do if abs(a[i]-tb)=min then break; write(tb:0:3,’ ‘,a[i]:0:3,’ ‘,i); readln END. Chúc bn hc tốt :> Trả lời