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;
const fo='songuyen.txt';
var f1:text;
a:array[1..10]of integer;
i,n:integer;
begin
clrscr;
assign(f1,fo); rewrite(f1);
repeat
write('n='); readln(n);
if (0>=n) or (n>10) then write('vui long nhap lai n');
until (0<n) and (n<=10);
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
if (-4>a[i]) or (5<a[i]) then write('vui long nhap lai a[',i,']');
until (-4<=a[i]) and (a[i]<=5);
end;
for i:=1 to n do
writeln(f1,a[i]);
close(f1);
readln;
end.
Câu 1:
uses crt;
var a,b,c,d,t:integer;
{------------------------chuong-trinh-con-tinh-tong-cua-hai-so-----------------}
function tong(var x,y:integer):integer;
begin
tong:=x+y;
end;
{------------------------chuong-trinh-chinh----------------------}
begin
clrscr;
write('Nhap so thu nhat: '); readln(a);
write('Nhap so thu hai: '); readln(b);
write('Nhap so thu ba: '); readln(c);
write('Nhap so thu tu: '); readln(d);
t:=tong(a,b)+tong(c,d);
writeln('Tong cua bon so la: ',t);
readln;
end.
Câu 2:
const fi='dulieu.dat';
assign(f1,fi); reset(f1);
uses crt;
const fi='bai1.inp';
var a,b:integer;
f:text;
begin
clrscr;
assign(f,fi); rewrite(f);
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
writeln(f,'a=',a);
writeln(f,'b=',b);
writeln(f,a,'+',b,'=',a+b);
close(f);
end.
uses crt;
var a,b,c,d,tb:real;
begin
clrscr;
write('Nhap diem cua ban:'); readln(a,b,c,d);
tb:=(a+b+c+d)/7;
if tb>=8 then writeln('Gioi');
if (6,5<=tb) and (tb<8) then writeln('Kha');
if (5<=tb) and (tb<6,5) then writeln('Trung Binh');
if tb<5 then writeln('Yeu');
readln;
end.
uses crt;
const finp='nhap.txt';
fout='xuat.txt';
type mang=array[1..10000] of longint;
var f:text;
n:longint;
a:mang;
{-----------------------------------------------------}
procedure doc;
var i:longint;
begin
assign(f,finp);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
close(f);
end;
{-----------------------------------------------------------------}
procedure ghi;
begin
assign(f,fout);
rewrite(f);
end;
{--------------------------------------------------------------}
function scp(x:longint):boolean;
begin
if sqr(round(sqrt(x)))=x then scp:=true
else scp:=false;
end;
{-------------------------------------------------------------}
procedure xuly;
var i,k:longint;
b:mang;
begin
for i:=1 to n do write(f,a[i],' ');
writeln(f);
k:=0;
for i:=1 to n do
if i mod 2<>0 then
begin
inc(k);
b[k]:=a[i]+a[i+1];
end;
for i:=1 to k do write(f,b[i],' ');
writeln(f);
for i:=1 to k do
if (b[i]>0) and (scp(b[i])) then write(f,b[i],' ');
end;
{--------------------------------------------------------}
begin
doc;
ghi;
xuly;
close(f);
end.
tuy có chút ko hỉu cho lắm nhưng dù sao vẫn cảm ơn bạn nhìu! <3
#include <bits/stdc++.h>
using namespace std;
double a,b,c;
int main()
{
freopen("input.inp","r",stdin);
freopen("output.inp","w",stdout);
cin>>a>>b>>c;
if (a+b>c && a+c>b && b+c>a && a>0 && b>0 && c>0) cout<<"tao thanh tam giac";
else cout<<"khong tao thanh tam giac";
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.
tổ ong
var S,N:int64;
f:text;
Begin
assign(f,'BEEHIVE.INP');
reset(f);
readln(f,N);
close(f);
if N=1 then S:=1
else S:=1+6*((N-1)*N div 2);
assign(f,'BEEHIVE.OUT');
rewrite(f);
writeln(f,S);
close(f);
end.
ốc sên
uses crt;
const
fi='SNAIL.INP';
fo='SNAIL.OUT';
Var a,b,v,x:longint;
f:text;
Begin
clrscr;
assign(f,fi);reset(f);
readln(f,a,b,v);
close(f);
x:=(V-a)div(a-b)+1;
if (V-a)mod(a-b)<>0 then inc(x);
assign(f,fo);rewrite(f);
writeln(f,x);
close(f);
end.
trên là 1 cách giải xin mọi người cho cách khác