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 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.
#include <bits/stdc++.h>
using namespace std;
int A[1000],n,i;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
sort(A+1,A+n+1);
for (int i=1; i<=n; i++)
cout<<A[i]<<" ";
cout<<endl;
for (int i=2; i<=n; i++)
cout<<A[i]-A[i-1]<<endl;
return 0;
}
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.
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.
có cách nào ngắn hơn không ạ