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.
tham khảo'
uses crt;
var a:array[1..100]of integer;
i,n,t,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chan la: ',t);
writeln('So luong so chan la: ',dem);
readln;
end.
Var a:array[1..100] of integer;
i,n,dem,vt,s sc,sl,min:integer;
tbc:real;
Begin
Write('Nhap so luong phan tu n = ');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 s:=s+a[i];
tbc:=s/n;
Writeln('Gia tri trung binh cua mang la ',tbc:10:2);
Write('Cac phan tu lon hon gia tri trung binh la ');
For i:=1 to n do
If a[i]>tbc then write(a[i],' ');
For i:=1 to n do
Begin
If a[i] mod 2 = 0 then sc:=sc+a[i]
Else sl:=sl+a[i];
End;
Writeln('Tong cac phan tu chan la ',sc);
Writeln('Tong cac phan tu le la ',sl);
min:=a[1];
For i:=2 to n do
Begin
If a[i] < min then min:=a[i];
vt:=i;
End;
Writeln('Phan tu nho nhat la ',min,' tai vi tri ',vt);
For i:=1 to n do
If a[i] mod 5 = 0 then dem:=dem+1;
Write('So cac phan tu chia het cho 5 la ',dem);
Readln;
End.
Câu 1:
uses crt;
var a:array[1..5]of integer;
max,i:integer;
begin
clrscr;
for i:=1 to 5 do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to 5 do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
Câu 2:
uses crt;
var a:array[1..6]of integer;
min,i:integer;
begin
clrscr;
for i:=1 to 6 do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to 6 do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[40],i,n,ln;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
ln=a[1];
for (i=1; i<=n; i++) ln=max(ln,a[i]);
for (i=n; i>=1; i--)
if (ln==a[i])
{
cout<<i;
break;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,nn,t;
int main()
{
cin>>n;
nn=LLONG_MAX;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
t+=x;
nn=min(nn,x);
}
cout<<nn<<" "<<t;
return 0;
}
Bài 23
var a:array[1..1000] of integer;
i,n:integer;
s,tbc:real;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
s:=s+a[i];
end;
tbc:=s/n;
writeln('Gia tri trung binh la ',tbc:10:2);
write('Cac so lon hon gia tri trung binh la: ');
for i:=1 to n do
if a[i] > tbc then write(a[i]:8);
readln
end.
var a:array[1..1000] of integer;
i,n,max:integer;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
end;
max:=a[1];
for i:=2 to n do
if a[i] > max then max:=a[i];
for i:=1 to n do
begin
if max=a[i] then write(max,' o vi tri thu ',i);
break;
readln
end.
Var array:[1..1000] of integer;
i,n:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
Write('Cac so le la ');
For i:=1 to n do
If a[i] mod 2 <> 0 then write(a[i]:8);
Readln
End.
Câu 1:
a) var a:array[1..50]of real;
b) a[5]:=8;
c) for i:=1 to 50 do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to 50 do
write(a[i]:4);
Câu 2:
uses crt;
var s,i:integer;
begin
clrscr;
s:=0;
for i:=1 to 10 do
s:=s+i;
writeln(s);
readln;
end.
for i:=1 to n do write(a[i]:4);