K
Khách

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.

function chia(x,y:integer):real;

begin

if y<>0 then chia:=x/y

else break;

end;

uses crt;

var x,y:integer;

{-------------------chuong-trinh-con-tong----------------------------}

function tong(a,b:integer):integer;

begin

tong:=a+b;

end;

{-------------------chuong-trinh-con-hieu----------------------------}

funtion hieu(a,b:integer):integer;

begin

hieu:=a-b;

end;

{-------------------chuong-trinh-con-tich----------------------------}

function tich(a,b:integer):integer;

begin

tich:=a*b;

end;

{-------------------chuong-trinh-con-thuong----------------------------}

function thuong(a,b:integer):real;

begin

thuong:=a/b;

end;

{----------------------chuong-trinh-chinh-----------------------}

begin

clrscr;

write('Nhap x='); readln(x);

write('Nhap y='); readln(y);

writeln('Tong la: ',tong(x,y));

writeln('Hieu la: ',hieu(x,y));

writeln('Tich la: ',tich(x,y));

writeln('Thuong la: ',thuong(x,y):4:2);

readln;

end.

uses crt;

const fi='kiemtra.txt';

var f1:text;

a:array[1..100]of integer;

min,n,i:integer;

{----------------chuong-trinh-con-------------------}

function nn(x,y:integer):integer;

begin

if x<y then nn:=x

else nn:=y;

end;

{-----------------chuong-trinh-chinh-----------------}

begin

clrscr;

write('nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

min:=nn(a[1],a[2]);

for i:=3 to n do 

  if min>a[i] then min:=a[i];

writeln(min);

readln;

end.

Mình xin sửa lại một chút:

uses crt;

const fi='kiemtra.txt';

var f1:text;

a:array[1..100]of integer;

min,n,i:integer;

{----------------chuong-trinh-con-------------------}

function nn(x,y:integer):integer;

begin

if x<y then nn:=x

else nn:=y;

end;

{-----------------chuong-trinh-chinh-----------------}

begin

clrscr;

assign(f1,fi); reset(f1);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

min:=nn(a[1],a[2]);

for i:=3 to n do 

  if min>a[i] then min:=a[i];

writeln(min);

readln;

end.

Bài 1: 

function canbac2(x:longint):real;

begin

canbac2:=sqrt(x);

end;

Bài 2: 

function tong(n:longint):longint;

var s,i:longint;

begin

s:=0;

for i:=1 to n do 

  s:=s+i;

tong:=s;

end;

29 tháng 4 2022

Var a,x2:integer;

Function bp(var i:integer);

Var b:integer;

Begin

Write('Nhap so can tinh ');readln(i);

b:=i*i;

Bp:=b;

End;

Begin

x2:=Bp(a);

Write(a,' binh phuong bang ',x2);

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.

uses crt;

var a:array[1..100]of integer;

min,n,i:integer;

{----------------chuong-trinh-con-------------------}

function nn(x,y:integer):integer;

begin

if x<y then nn:=x

else nn:=y;

end;

{-----------------chuong-trinh-chinh-----------------}

begin

clrscr;

write('nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

min:=nn(a[1],a[2]);

for i:=3 to n do 

  if min>a[i] then min:=a[i];

writeln(min);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,t;

int main()

{

cin>>n;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x<0) t+=x;

}

cout<<t;

return 0;

}