Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
uses crt;
var a:array[1..200]of integer;
i,n,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('Gia tri lon nhat la: ',max);
write('Vi tri la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
readln;
end.
uses crt;
var i,n,c,b,uc:integer;
bcnn:int64;
a:array[1..100] of integer;
{--------------------------chuong-trinh-con-tim-ucln-cua-hai-so---------------}
function ucln(c,b:integer):integer;
var r:integer;
begin
r:=c mod b;
while r<>0 do
begin
c:=b;
b:=r;
r:=c mod b;
end;
ucln:=b;
end;
{---------------------------chuong-trinh-chinh-----------------------------------}
begin
clrscr;
Write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
uc:=ucln(a[1],a[2]);
for i:=3 to n do
uc:=ucln(uc,a[i]);
writeln(uc);
readln;
end.
Bai 2:
uses crt;
var a:array[1..100]of integer;
i,n,t,nn:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
nn:=a[1];
for i:=1 to n do
if nn>a[i] then nn:=a[i];
write(nn);
readln;
end.
program du_lieu;
uses crt;
var i,n:integer;
a:array[1..100]of integer;
tbc:real;
f:text;
begin
clrscr;
assign(f,'DULIEU.INP');reset(f);
readln(f,n);
for i:=1 to n do
begin
read(f,a[i]);
end;
close(f);
for i:=1 to n do
tbc:=tbc+a[i];
writeln(tbc/n);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,k:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
writeln('Trong day co ',dem,' phan tu co gia tri bang ',k);
readln;
end.
#include <iostream>
#include <fstream>
using namespace std;
ifstream input("D:/input.txt");
ofstream output("D:/ouput.txt");
int main()
{
int A[1000];
int n ,dem=0;
input >> n;
for(int i=0;i<n;i++)
input >> A[i];
for(int i=0;i<n;i++)
if(A[i]<0)
dem +=A[i];
output << dem;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i]<0 then t:=t+a[i];
writeln('Tong cac so nguyen am la: ',t);
readln;
end.