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 i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
if i mod 2=1 then write(i:4);
for i:=1 to n do
if i mod 2=0 then write(i:4);
readln;
end.
Program HOC24;
var min,j,i,n,tg: integer;
t: longint;
a: array[1..1000] of integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ') else t:=t+a[i];
writeln; writeln('Tong cac so le la: ',t);
min:=a[1];
for i:=2 to n do if a[i]<min then min:=a[i];
writeln('So nhat nhat la: ',min);
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;
for i:=1 to n do write(a[i],' ');
readln
end.
Uses crt;
var i,n,min,k,e,j: longint
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(n); readln;
for i:=1 to n do if(a[i] mod 2=0) then write(a[i],' ');
for i:=1 to n do if(a[i] mod 2<>0) then k:=k+a[i];
min:=a[i];
for i:=1 to n do if(min>a[i]) then min:=a[i];
writeln(min);
for i:=1 to n-1 do
for j:=i+1 to n do if a[j] <=a[i] then
begin e:= a[i];
a[i]:=a[j];
a[j]:=e; end;
for i:=1 to n do write(a[i],';');
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+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('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+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('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.
Program Tin_hoc;
Uses crt;
Var i,tam,n,chan,le,j:integer;
a,daychan,dayle:array[1..10000] of integer;
Begin
clrscr;
Write('Nhap n: ');readln(n);
chan:=0;le:=0;
Writeln('Nhap ',n,' phan tu cua mang:');
For i:= 1 to n do
Begin
write('A[',i,'] = ');
Readln(a[i]);
If a[i] mod 2 = 0 then
Begin
inc(chan);
daychan[chan]:=a[i];
end
else
Begin
inc(le);
dayle[le]:=a[i];
End;
End;
For i:= 1 to chan do
for j:= i to chan do If daychan[i]>daychan[j] then
Begin
tam:=daychan[i];
daychan[i]:=daychan[j];
daychan[j]:=tam;
End;
For i:= 1 to le do
for j:= i to le do If dayle[i]<dayle[j] then
Begin
tam:=dayle[i];
dayle[i]:=dayle[j];
dayle[j]:=tam
End;
Writeln('Day sau khi sap xep:');
For i:= 1 to chan do write(daychan[i],' ');
For i:= 1 to le do write(dayle[i],' ');
Readln;
End.
uses crt;
var a:array[1..100]of integer;
i,n,t,kt,j:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t+a[i];
writeln(t);
for i:=1 to n do
if trunc(sqrt(a[i]))=sqrt(a[i]) then write(a[i]:4);
writeln;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then write(a[i]:4);
end;
readln;
end.
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.
#include <bits/stdc++.h>
using namespace std;
int A[100],B[100],C[100],kt,n,nn,dem1=0, dem2=0;
int main()
{
cin>>n;
for (int i=1; i<=n; i++)
cin>>A[i];
kt=0;
nn=INT_MAX;
for (int i=1; i<=n; i++)
if (A[i]%2!=0)
{
kt=1;
if (nn>=A[i]) nn=A[i];
}
if (kt==0) cout<<"khong co";
else cout<<nn;
cout<<endl;
for (int i=1; i<=n; i++)
if (A[i]%2==0 && A[i]>7)
cout<<A[i]<<" ";
cout<<endl;
for (int i=1; i<=n; i++)
if (A[i]%2!=0)
{
dem1++;
B[dem1]=A[i];
}
for (int i=1; i<=n; i++)
if (A[i]%2==0)
{
dem2++;
C[dem2]=A[i];
}
sort(B,B+dem1+1);
sort(C,C+dem2+1);
for (int i=dem1; i>=1; i--)
cout<<B[i]<<" ";
for (int i=1; i<=dem2; i++)
cout<<C[i]<<" ";
}