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.
Var a:array[1..30] of integer;
i,n,d,max:integer;
Begin
Write('Nhap so luong phan tu cua mang ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
max:=a[1];
For i:=2 to n do
Begin
If a[i] > max then
Begin
max:=a[i];
d:=i;
End;
End;
Write('Phan tu lon nhat la ',max,' o vi tri ',d);
Readln;
End.
Var a:array[1..30] of integer;
i,n,d,max:integer;
Begin
Write('Nhap so luong phan tu cua mang ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
max:=a[1];
For i:=2 to n do
Begin
If a[i] > max then
Begin
max:=a[i];
d:=i;
End;
End;
Write('Phan tu lon nhat la ',max,' o vi tri ',d);
Readln;
End.
Var a:array[1..30] of integer;
i,max,d:integer;
Begin
For i:=1 to 30 do
Begin
Repeat
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
Until a[i]<=255;
End;
max:=a[1];
d:=1;
For i:=2 to 30 do
If a[i] > max then
Begin
max:=a[i];
d:=i;
End;
Write('Phan tu lon nhat la ',max,' tai vi tri ',i);
Readln
End.
#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];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) t+=a[i];
cout<<t;
return 0;
}
Var a:array[1..1000] of integer;
i,m,tam:integer;
Begin
Write('m = ');readln(m);
For i:=1 to m do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to m do
If a[i] < a[i+1] then
Begin
tam:=a[i];
a[i]:=a[i+1];
a[i+1]:=tam;
End;
Write('Mang sau khi sap xep: ');
For i:=1 to m do
Write(a[i]:8);
Readln;
End.
uses crt;
var b:array[1..25]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
readln;
end.
bạn tham khảo
uses crt;
var a:array[1..200]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.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem1,dem2;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
if (a[i]%2==0) dem1++;
else dem2++;
}
cout<<dem1<<" "<<dem2;
return 0;
}
Câu 1:
uses crt;
var a:array[1..10]of integer;
i,n,k,t:integer;
begin
clrscr;
write('nhap n='); readln(n);
if (0<n) and (n<=10) then
begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('nhap k='); readln(k);
{----------------------------cau-a-------------------------}
writeln('cac phan tu lon hon hoac bang ',k,' trong day la: ');
for i:=1 to n do
if a[i]>=k then write(a[i]:4);
{--------------------------cau-b-------------------------------}
writeln;
t:=0;
for i:=1 to n do
if a[i]>=k then t:=t+a[i];
writeln('tong cac phan tu lon hon hoac bang ',k,' la: ',t);
end
else writeln('vui long nhap lai');
readln;
end.
Câu 2:
uses crt;
var a:array[1..10]of integer;
i,n,tam,j,k:integer;
begim
clrscr;
write('nhap n='); readln(n);
if (0<n) and (n<=10) then
begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('nhap k='); readln(k);
writeln('Day truoc khi sap xep la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
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 sap xep tang dan la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
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 sap xep giam dan la: ');
for i:=1 to n do
write(a[i]:4);
end
else writeln('vui long nhap lai');
readln;
end.
Tớ cảm ơn c nhiều ạ