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[5],i;
int main()
{
for (i=1; i<=5; i++) cin>>a[i];
sort(a+1,a+5+1);
cout<<"Tong nho nhat la: "<<a[1]+a[2]+a[3]+a[4]<<endl;
cout<<"Tong lon nhat la: "<<a[5]+a[4]+a[3]+a[2];
return 0;
}
Program HOC24;
var i,n,vt1,vt2,max,min: integer;
a: array[1..1000] of integer;
begin
readln(n);
for i:=1 to n do read(a[i]);
readln;
max:=0; min:=32000;
for i:=1 to n do
begin
if a[i]>max then
begin
max:=a[i];
vt1:=i;
end;
if a[i]<min then
begin
min:=a[i];
vt2:=i;
end;
end;
writeln(max,' ',vt1);
write(min,' ',vt2);
readln
end.
uses crt;
type mang= array[0..10000 ] of byte;
var a,d,m:mang; dd:array[1..20,1..400] of byte;
b:array [1..10000] of boolean;
r,dem, t,n,max,i,j:integer;
f:text;
procedure doc;
var i:integer;
begin
assign(f,'pthuong.inp');
reset(f);
readln(f,n);
for i:=1 to n do
readln(f,d[i]);
close(f);
end;
function kt( c:mang):boolean;
var i,j:longint;
q:boolean;
begin
i:=1;
q:=true;
while (i<=r-2) and q do
begin
j:=1;
while c[i+j-1]+1=c[i+j] do
j:=j+1;
if j>=3 then q:=false else q:=true;
i:=i+1;
end;
kt:=q;
end;
Procedure print;
var i,tong: byte;
begin if kt(a)=true then
begin dem:=dem+1;
tong:=0;
for i:=1 to r do
begin
dd[dem,i]:= a[i];
tong:=tong+d[a[i]];
end; m[dem]:=tong;
end;
end;
Procedure Find(k:byte);
var j: byte;
begin
if k>r then print else
begin
for j:=1 to n do
if b[j] and (j>a[k-1]) then
begin
a[k]:=j; b[j]:=false;
Find(k+1);
b[j]:=true;
end;
end;
end;
begin
clrscr;
doc;
dem:=0;
r:= n-(n div 3);
for t:=1 to n do
b[t]:=true; a[0]:=0;
Find(1);
max:=m[1];
for i:=1 to dem do
if max< m[i] then max:=m[i];
assign(f,'PTHUONG.OUT');
rewrite(f);
writeln(f,max);
for i:=1 to dem do
if max=m[i] then
begin
j:=1;
while (dd[i,j] <>0) do
begin
write(f,dd[i,j]:2);
j:=j+1;
end;
end;
close(f);
end.
Bạn tham khảo bộ code này nhé.
uses crt;
var n,n1,s:real;
begin
clrscr;
write('Nhap n: ');readln(n);
n1:=2*n+1;
s:=((n1 - 1)/2+1)*(n1 + 1)/2;
write(s:0:0);
readln
end.
Bài 7:
#include <bits/stdc++.h>
using namespace std;
long long n,a,b,c,d;
int main()
{
cin>>n;
a=n%10;
b=n/10; b=b%10;
c=n/100; c=c%10;
d=n/100; d=d%10;
if (a+b==c+d) cout<<"YES";
else cout<<"NO";
return 0;
}