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.
Program HOC24;
var a: array[1..15] of integer;
tg,i,n,j: integer;
begin
n:=15;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
for i:=1 to 7 do
for j:=i+1 to 8 do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
for i:=9 to 14 do
for j:=i+1 to 15 do
if a[i]<a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
for i:=1 to n do write(a[i],' ');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long a[100],b[100],c[100],n,i,dem1,dem2;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
if (a[i]%2==0)
{
dem1++;
b[dem1]=a[i];
}
else
{
dem2=0;
c[dem2]=a[i];
}
}
sort(b+1,b+dem1+1);
sort(c+1,c+dem2+1);
for (i=1; i<=dem1; i++)
cout<<b[i]<<" ";
for (i=dem2; i>=1; i--)
cout<<c[i]<<" ";
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem,t,tb:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if a[i]>0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('So luong phan tu duong la: ',dem);
writeln('Tong cac phan tu duong la: ',t);
writeln('Trung binh cac phan tu duong la: ',t/dem:4:2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,dem;
int main()
{
cin>>n;
for(i=1; i<=n; i++) cin>>a[i];
dem=0;
for (i=1; i<=n; i++) if (a[i]%10==0) dem++;
cout<<"So luong so chia het cho 2 va 5 la: "<<dem<<endl;
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,chon;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
cin>>chon;
if (chon==0)
{
for (i=1; i<=n; i++) cout<<a[i]<<" ";
}
else
{
for (i=n; i>=1; i--) cout<<a[i]<<" ";
}
return 0;
}
uses crt;
var a,b,c:array[1..100,1..100]of integer;
i,j,n,m,tam,k,tam1,i1,j1,i2,j2,tg:integer;
begin
clrscr;
write('nhap n='); readln(n);
write('nhap m='); readln(m);
for i:=1 to n do
for j:=1 to m do
begin
write('a[',i,',',j,']=');readln(a[i,j]);
end;
{--------------------gan-mang-A-cho-mang-B------------------------------}
for i:=1 to n do
for j:=1 to m do
b[i,j]:=a[i,j];
{-------------------gan-mang-A-cho-mang-C------------------------------}
for i:=1 to n do
for j:=1 to m do
c[i,j]:=a[i,j];
{---------------------------cau-a---------------------------}
for i:=1 to n do
begin
for j:=1 to m-1 do
for k:=j+1 to m do
if a[i,j]>a[i,k] then
begin
tam:=a[i,j];
a[i,j]:=a[i,k];
a[i,k]:=tam;
end;
end;
for i:=1 to n do
begin
writeln('day tang dan cua dong ',i,' la: ');
for j:=1 to m do
write(a[i,j]:4);
writeln;
end;
{---------------------------cau-b---------------------------}
for i:=1 to n-1 do
for k:=i+1 to n do
begin
for j:=1 to m do
if b[i,j]>b[k,j] then
begin
tam1:=b[i,j];
b[i,j]:=b[k,j];
b[k,j]:=tam1;
end;
end;
for j:=1 to m do
begin
writeln('day tang dan cua cot ',j,' la: ');
for i:=1 to n do
write(b[i,j]:4);
writeln;
end;
{-----------------------------------cau-c------------------------------}
writeln('ma tran tang dan zig zac cua day A la: ');
for i1:=1 to n do
for j1:=1 to m do
for i2:=1 to n do
for j2:=1 to m do
if c[i1,j1]<c[i2,j2] then
begin
tg:=c[i1,j1];
c[i1,j1]:=c[i2,j2];
c[i2,j2]:=tg;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(c[i,j]:4);
writeln;
end;
readln;
end.