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.
1)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] > a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep tang dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
2)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] < a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep giam dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
uses crt;
var a: array[1..100] of longint;
i,n,max,min: longint;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': ');
readln(a[i]);
end;
max:=a[1]; min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('So lon nhat trong mang la: ',max);
write('So nho nhat trong mang la: ',min);
readln
end.
Câu 1:
Program HOC24;
var a: array[1..1000] of integer;
i,n: integer; tbc: real;
begin
write('Nhap so phan tu trong mang: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
tbc:=0;
for i:=1 to n do tbc:=tbc+a[i];
tbc:=tbc/n;
write('Trung binh cong la: ',tbc:6:2);
readln
end.
Câu 2:
Program HOC24;
var a: array[1..1000] of integer;
i,n,h,tg: integer;
begin
write('Nhap so phan tu trong mang: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
for i:=1 to n do
for j:=i to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
write('Mang sau khi sap xep la: ');
for i:=1 to n do write(a[i].' ');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long dem,x,n,i,t;
int main()
{
cin>>n;
t=0;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0)
{
dem++;
t+=x;
}
}
cout<<dem<<" "<<t;
return 0;
}
Uses crt;
var n,i,max,min: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(a[i]); readln;
max:=a[1];
for i:=1 to n do if(max<a[i]) then max:=a[i];
writeln(max);
min:=a[1];
for i:=1 to n do if(min>a[i]) then min:=a[i];
writeln(min);
readln;
end.
uses crt;
var a: array[1..100] of integer;
i: longint;
begin
clrscr;
for i:=1 to 20 do readln(a[i]);
writeln('day vua nhap la:');
for i:=1 to 20 do write(a[i],' ');
readln
end.
uses crt;
var a:array[1..20]of integer;
i,n:integer;
begin
clrscr;
n:=20;
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.