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:array[1..1000]of integer;
i,n,j,tam,t,t1,tam,dem,max:integer;
begin
clrscr;
n:=0;
t:=0;
repeat
inc(n);
write('A[',n,']='); readln(a[n]);
t:=t+a[n];
until t>100;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('Day so theo chieu tang dan la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t1:=0;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then
begin
t1:=t1+a[i];
inc(dem);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('Tong cac so la boi cua 3 la: ',t1);
writeln('So lon nhat cua day la: ',max);
writeln('So luong so la boi cua 3 la: ',dem);
readln;
end.
uses crt;
var n,t1:integer;
s:real;
begin
clrscr;
t1:=0;
s:=1;
repeat
readln\(\left(n\right)\);
if n mod 2=0 then t1:=t1+n
else s:=s*n;
until n=0;
writeln\(\left(t1\right)\);
writeln\(\left(s:4:2\right)\);
readln;
end.
Tham Khảo:
uses crt;
var a:array[1..100]of integer;
i,n,j,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);</p><p>for i:=1 to n do</p><p> begin</p><p>write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
Var a:array[1..200] of integer;
i,n,s,s1:integer;
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;
writeln('Cac so vua nhap la ');
for i:=1 to n do
write(a[i],' ');
for i:=1 to n do
if a[i] > 0 then s:=s+a[i];
for i:=1 to n do
if a[i] mod 2 = 1 then s1:=s1+a[i];
writeln('Tong cac so nguyen duong trong day la ',s);
write('Tong cac so le la ',s1);
readln;
end.
Bài 1:
program in_phan_tu;
uses crt;
var n,i:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:3);
readln;
end.
Bài 2:
program tong_phan_tu;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Bài 3:
program tong_phan_tu_chan;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
if a[i] mod 2=0 then tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Câu 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
write(a[i]:4);
readln;
end.
uses crt;
var a,b,c,ln,nn:integer;
tbc:real;
begin
clrscr;
readln(a,b,c);
ln:=a;
if ln<b then ln:=b;
if ln<c then ln:=c;
nn:=a;
if nn>b then nn:=b;
if nn>c then nn:=c;
writeln(ln);
writeln(nn);
tbc:=(a+b+c)/3;
if a>tbc then write(a,' ');
if b>tbc then write(b,' ');
if c>tbc then write(c,' ');
writeln;
if a=tbc then write(a,' ');
if b=tbc then write(b,' ');
if c=tbc then write(c,' ');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main ()
{
int a[32];
int n,i,s;
cout<<"nhap so phan tu cua mang ";
cin>>n;
cout<<"nhap cac phan tu cua mang ";
for (i=1; i<=n; i++)
{
s=0;
cin>>a[i];
}
for(i=1; i<=a[i]; i++) s=s+i;
cout<<s;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,s,t,ln,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
s=1;
t=0;
ln=a[1];
nn=a[1];
for (i=1; i<=n; i++)
{
s=s*a[i];
t+=a[i];
ln=max(ln,a[i]);
nn=min(nn,a[i]);
}
cout<<s<<endl;
cout<<t<<endl;
cout<<ln<<endl;
cout<<nn;
return 0;
}
uses crt;
var n,t:integer;
begin
clrscr;
t:=0;
dem:=0;
repeat
write('nhap n='); readln(n);
t:=t+n;
dem:=dem+1;
until t>1997;
writeln('Trung binh cong cua cac so da nhap la: ',t/dem:4:2);
readln;
end.