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.

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 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.

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.

#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;

}

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,t;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

t=0;

for (i=1; i<=n; i++) t+=a[i];

cout<<t<<endl;

sort(a+1,a+n+1);

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

23 tháng 2 2023

Bài 1

Var s,i:integer;

tb:real;

Begin

Write('Nhap n = ');readln(n);

i:=1;

s:=0;

While i<=n do

Begin

s:=s+i;

i:=i+1;

End;

tb:=s/n;

Writeln('Tong la ',s);

Write('Trung binh la ',tb:10:2);

Readln;

End.

23 tháng 2 2023

Bài 2

Var i,n,souoc:integer;

Begin

Write('Nhap n = ');readln(n);

i:=1;

While i <= n do

Begin

i:=i + 1;

If n mod i = 0 then souoc:=souoc + 1;

End;

If souoc = 1 then write(n,' la so nguyen to')

Else write(n,' khong la so nguyen to');

Readln;

End.

Cái này mình viết chương trình chính thôi, bạn tự viết ctc nhé

Câu 1: 

uses crt;

var n,i,s:longint;

begin

clrscr;

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

s:=1;

for i:=1 to n do

 s:=s*i;

writeln(s);

readln;

end.

Câu 2: 

uses crt;

var st:string;

i,d:integer;

begin

clrscr;

write('Nhap xau:'); readln(st);

d:=length(st);

for i:=d downto 1 do 

  write(st[i]);

readln;

end.

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] mod 2=0 then t:=t+a[i];

writeln(t);

readln;

end.