Những câu hỏi liên quan
Phan Thị Thùy Ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 5 2021 lúc 22:29

Câu 2: 

uses crt;

var a,b:integer;

{-----------------chuong-trinh-con-------------------}

function ucln(x,y:integer):integer;

var i,uc:integer;

begin

if x<y then 

begin

uc:=1;

for i:=1 to x do 

  if (x mod i=0) and (y mod i=0) then  

begin

if uc<i then uc:=i;

end;

end

else begin

uc:=1;

for i:=1 to y do 

  if (x mod i=0) and (y mod i=0) then  

begin

if uc<i then uc:=i;

end;

end;

ucln:=uc;

end;

{--------------------------chuong-trinh-chinh------------------------}

begin

clrscr;

write('Nhap a='); readln(a);

write('Nhap b='); readln(b);

writeln(a,'/',b,'=',a div ucln(a,b),'/',b div ucln(a,b));

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
2 tháng 5 2021 lúc 22:30

Câu 1: 

const fi='songuyen.inp'

fo='tong.out'

var f1,f2:text;

a:array[1..100]of integer;

i,n,t:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

n:=0;

while not eoln(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

t:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then t:=t+a[i];

writeln(f2,t);

close(f1);

close(f2);

end.

Bình luận (0)
Nguyễn Đức Anh Khoa
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 1 2021 lúc 12:30

const fi='tong.inp'

fo='tong.out'

var f1,f2:text;

a:array[1..100]of integer;

n,i,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]);

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(f2,t);

close(f1);

close(f2);

end.

Bình luận (0)
Thị Cúc Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 3 2022 lúc 14:07

#include <bits/stdc++.h>

using namespace std;

long long a,b;

int main()

{

freopen("dulieu.txt","r",stdin);

freopen("ketqua.txt","w",stdout);

cin>>a>>b;

cout<<max(a,b);

return 0;

}

Bình luận (0)
Mĩ Lâm
Xem chi tiết
Nguyên Hưng Trần
22 tháng 7 2021 lúc 21:25

Uses crt;
var f1,f2:text;
    i,n,tong,tongchan,dem:integer;
    tb:real;
Begin
 clrscr;
 Assign(f1,'DAYSO.txt');
 Assign(f2,'KETQUA.txt');
 reset(f1);dem:=0;tong:=0;tongchan:=0;
 While Not EOF(f1) do
  Begin
  read(f1,i);
  inc(tong,i);
  If i mod 2 = 0 then
    begin
    inc(dem);
    inc(tongchan,i);
    end;
  End;
 tb:=tongchan/dem;
 close(f1);
 rewrite(f2);
 writeln(f2,tong);
 writeln(f2,tongchan);
 writeln(f2,tb:0:2);
 close(f2);
 write(tong);
 readln;
End.

Bình luận (0)
No One Actually
Xem chi tiết
No One Actually
11 tháng 4 2021 lúc 20:11

help

 

Bình luận (0)
Nguyễn Lê Phước Thịnh
12 tháng 4 2021 lúc 13:04

const fi='input.txt'

fo='output.txt'

var f1,f2:text;

a,b,c,max:real;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,a,b,c);

min:=a;

if min>b then min:=b;

if min>c then min:=c;

writeln(f2,min);

close(f1);

close(f2);

end.

Bình luận (0)
Minh
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 5 2021 lúc 13:08

const fi='input.inp'

fo='output.out'

var a,b:integer;

f1,f2:text;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,a,b);

if a<b then writeln(f2,a)

else writeln(f2,b);

close(f1);

close(f2);

end.

Bình luận (1)
Kiên Tạ
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2021 lúc 20:46

const fi='dulieu.txt'     

fo='ketqua.txt'

var f1,f2:text;   

a,b,c,d:array[1..100]of integer;   

i,n,dem,dem1:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

n:=0;

while not eof(f1) do 

begin     

n:=n+1;     

readln(f1,a[n],b[n]); 

end;

dem:=0;

dem1:=0;

for i:=1 to n do 

if a[i]>b[i] then     

begin       

inc(dem);       

inc(dem1);       

c[dem]:=a[i];       

d[dem]:=b[i];     

end 

else begin         

inc(dem);         

inc(dem1);         

c[dem]:=b[i];         

d[dem]:=a[i];       

end;

for i:=1 to dem do 

write(f2,c[i]:4);

writeln(f2);

for i:=1 to dem1 do 

write(f2,d[i]:4);

close(f1);

close(f2);

end.

Bình luận (0)
hoichut
Xem chi tiết
Dania sunna
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 12 2021 lúc 23:23

#include <bits/stdc++.h>

using namespace std;

long long a,b,c,d;

int main()

{

freopen("input.txt","r",stdin);

freopen("output.txt","w",stdout);

cin>>a>>b>>c>>d;

cout<<a+b+c+d;

return 0;

}

Bình luận (0)