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.
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<min(a,b)<<" "<<max(a,b)<<endl;
cout<<max(a,b)<<" "<<min(a,b)<<endl;
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.
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<min(a,b)<<" "<<max(a,b);
return 0;
}
Uses crt;
var n,i,x,u: integer;
begin clrscr;
readln(n);
for i:=1 to n do begin
readln(x);
u:=u+x;
end;
writeln(u);
readln;
end.
-so sanh hai so nhap tu ban phim:
var a,b:integer;
begin
clrscr;
write('Nhap so thu nhat:');readln(a);
write('Nhap so thu hai:');readln(b);
if a>b then writeln(a,'lon hon',b)
else writeln(a,'nho hon,'b);
if a=b then writeln(a,'bang',b);
readln;
end.
program ctdt;
uses crt;
type mang=array[1..10]of integer;
var a,b,min,x,y,i,j,tam:integer;
t,t1:mang;
(*------------------------*)
BEGIN
clrscr;
(*cau a*)
write('nhap 2 so:');readln(a,b);
if a>b then writeln(a,' lon hon ',b);
if a=b then writeln(a,' bang ',b);
if a<b then writeln(a,' nho thua ,b);
(*cau b*)
for i:=1 to 4 do {dua 4 so vao 1 mang}
begin
write(so thu ',i,' :');readln(t[i]);
end;
min:=t[1];
for i:=2 to 4 do
if t[i]<min then min:=t[i];
writeln('so nho nhat trong bon so:',min);
(*cau c*)
write('nhap hai so x,y:');readln(x,y);
if x>y then
begin
tam:=x;
x:=y;
y:=tam;
end;
(*cau d*)
for i:=1 to 3 do {dua 3 so vao mot mang}
begin
write(' so thu ',i,': ');readln(t1[i]);
end;
for i:=1 to 3-1 do
for j:=i+1 to 3 do
if t1[j]>t1[i] then
begin
tam:=t1[j];
t1[j]:=t1[i];
t1[i]:=tam;
end;
for i:=1 to 3 do
write(t1[i]);
readln;
end.
bai nay con vai loi sai nho
ban nen chay tung cau mot va khoa cac cau con lai bang lenh {...}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
cin >>x>>y;
cout<<x<<" "<<y;
swap(x,y);
cout<<x<<" "<<y;
return 0;
}
#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;
}