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.

uses crt;

var a,b:integer;

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

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

begin

tong:=x+y;

end;

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

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

begin

tich:=x*y;

end;

{-----------------chuong-trinh-con-so-lon------------------}

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

begin

if x>y then solon:=x

else solon:=y;

end;

{-----------------chuong-trinh-con-so-be------------------}

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

begin

if x<y then sobe:=x

else sobe:=y;

end;

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

begin

clrscr;

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

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

writeln('Tong la: ',tong(a,b));

writeln('Tich la: ',tich(a,b));

writeln('So lon la: ',solon(a,b));

writeln('So be la: ',sobe(a,b));

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;

}

15 tháng 4 2023

def sum_and_diff(m, n):
    sum = m + n
    diff = m - n
    return sum, diff

# sử dụng chương trình con
a = 5.6
b = 2.3
result = sum_and_diff(a, b)
print("Tổng và hiệu của", a, "và", b, "là", result)

uses crt;

const fi='tep.txt';

var f1:text;

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

i,n,kt,j,dem:integer;

begin

clrscr;

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

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

readln(f1,a[n]);

end;

dem:=0;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to a[i]-1 do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then inc(dem);

end;

writeln(dem);

close(f1);

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;

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.

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.