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 a,b:integer;
begin
clrscr;
readln(a,b);
write((a+b)*2);
readln;
end.
uses crt;
const fi='dulieu.dat';
var f1:text;
a,b,p,s:array[1..100]of real;
i,n:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(a[n],b[n]);
end;
for i:=1 to n do
begin
p[i]:=(a[i]+b[i])/2;
s[i]:=a[i]*b[i];
end;
for i:=1 to n do
writeln(p[i]:4:2,' ',s[i]:4:2);
close(f1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
freopen("hcn.inp","r",stdin);
freopen("hcn.out","w",stdout);
cin>>a>>b;
cout<<(a+b)*2<<endl;
cout<<a*b;
return 0;
}
#include <iostream>
#include <fstream>
using namespace std;
long int x[4],n,a[5001],kt[5001],ktvt[5001],MAXtong,dem=0;
int TRY(int i)
{
for(int j=x[i-1]+1;j<=n;j++)
if(kt[a[j]]==0)
{
x[i]=j;
kt[a[j]]=1;
if(i==3)
{
if(a[x[3]]==(float)(a[x[2]]+a[x[1]])/2||a[x[2]]==(float)(a[x[3]]+a[x[1]])/2||a[x[1]]==(float)(a[x[2]]+a[x[3]])/2)
{
dem++;
if(a[x[1]]+a[x[2]]+a[x[3]]>MAXtong)
{
MAXtong=a[x[1]]+a[x[2]]+a[x[3]];
}
}
}
else
TRY(i+1);
kt[a[j]]=0;
}
}
int main()
{
ifstream f("boba.inp");
f>>n;
for(int i=1;i<=n;i++)
{
f>>a[i];
}
x[0]=0;
MAXtong=-1000000000;
fill_n(kt,1001,0);
TRY(1);
cout<<dem<<endl;
if(dem>0)
{
cout<<MAXtong;
}
return 0;
}
Mình mới đạt tới trình độ quy hoạch động nên bạn thông cảm
Xin lỗi bạn, mình không hỗ trợ C. mình chỉ biết pascal thôi
const fi='tamhop.inp';
fo='tamhop.out';
var f1,f2:text;
a:array[1..100]of integer;
n,i,j,k,dem,max,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
{--------------------------------xu-ly--------------------------------}
dem:=0; max:=0;
for i:=1 to n-2 do
begin
for j:=i+1 to n-1 do
begin
for k:=j+1 to n do
begin
if (a[i]=(a[j]+a[k])/2) or (a[j]=(a[i]+a[k])/2) or (a[k]=(a[i]+a[j])/2) then
begin
inc(dem);
t:=a[i]+a[j]+a[k];
if max<=t then max:=t;
end;
end;
end;
end;
writeln(f2,dem);
writeln(f2,max);
close(f1);
close(f2);
end.
Program hotrotinhoc;
var a,b,i: word;
function nt(x: word) : boolean;
var j: integer;
begin
nt:=true;
if (x=2) or (x=3) then exit;
nt:=false;
if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;
j:=6;
while j<=trunc(sqrt(x)) do
begin
if (x mod j=0) or (x mod (j+2)=0) then exit;
i:=i+5;
end;
nt:=true;
end;
begin
readln(a,b);
for i:=a to b do if nt(i) then writeln(i);
readln
end.
uses crt;
var a,b,kt,i,j:integer;
begin
clrscr;
write('nhap a='); readln(a);
write('nhap b='); readln(b);
if a<b then
begin
for i:=a to b do
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then writeln(i);
end;
end;
readln;
end.
const fi='hcn.inp';
fo='hcn.out';
var f1,f2:text;
a,b:array[1..100]of integer;
i,j,n:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
inc(n);
readln(f1,a[n],b[n]);
end;
for i:=1 to n do
writeln(f2,2*(a[i]+b[i]),' ',a[i]*b[i]);
close(f1);
close(f2);
end.
#include<iostream>
using namespace std;
int main() {
int a,b;
cin >> a >> b;
cout << (a+b)*2;
return 0;
}