Những câu hỏi liên quan
haizzz!!
Xem chi tiết
nguyễn an phát
3 tháng 4 2021 lúc 12:02

program tim_chu_so;

uses crt;

var i,n,csln:longint;

k:integer;

a:array[1..1000]of longint;

st:string;

begin

clrscr;

write('nhap so n:');readln(n);

str(n,st);

val(st,a[i]);

csln:=a[1];

for i:=1 to length(st) do

if csln<a[i] then csln:=a[i];

writeln('chu so lon nhat cua so ',n,' la:',csln);

readln;

end.

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

Câu 1: 

uses crt;

var n,i,d,x,y,max:integer;

st:string;

begin

clrscr;

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

str(n,st);

d:=length(st);

max:=0;

for i:=1 to d do 

  begin

val(st[i],x,y);

if max<x then max:=x;

end;

writeln('Chu so lon nhat la: ',max);

readln;

end. 

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

Câu 2: 

uses crt;

var a,b,i,bcnn:longint;

begin

clrscr;

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

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

bcnn:=a*b;

for i:=a*b-1 downto 1 do 

  if (i mod a=0) and (i mod b=0) then 

begin

if bcnn<i then bcnn:=i;

end;

writeln('Boi chung nho nhat la: ',bcnn);

readln;

end.

Bình luận (0)
hồng trương
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 1 2022 lúc 22:14

#include <bits/stdc++.h>

using namespace std;

long long a,b;

int main()

{

cin>>a>>b;

cout<<max(a,b);

return 0;

}

Bình luận (0)
Kiều Vũ Linh
13 tháng 1 2022 lúc 11:28

Var a,b:integer;

Begin

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

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

If a > b then write('so lon nhat la ',a)

Else if b > a then write('so lon nhat la ',b)

Else write('khong co so lon nhat');

Readln;

End.

Bình luận (0)
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)
Linh Chii
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 5 2021 lúc 17:04

1:

uses crt;

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

i,n,max:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

max:=a[1];

for i:=1 to n do 

  if max<a[i] then max:=a[i];

writeln(max);

readln;

end.

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

2:

uses crt;

var s:real;

i:integer;

begin

clrscr;

s:=0;

for i:=1 to 100 do 

  s:=s+1/i;

writeln(s:4:2);

readln;

end.

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

Bài 1:

uses crt;

var n,i,s:integer;

begin

clrscr;

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

s:=0;

for i:=1 to n do 

 if i mod 6=0 then s:=s+i;

writeln(s);

readln;

end.

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

Bài 2: 

uses crt;

var a,b,c,ucln,i:integer;

begin

clrscr;

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

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

write('c='); readln(c);

while a<>b do 

  begin

if a>b then a:=a-b

else b:=b-a;

end;

ucln:=a;

while ucln<>c do 

 begin

if ucln>c then ucln:=ucln-c

else c:=c-ucln;

end;

writeln(ucln);

readln;

end.

Bình luận (0)
Yoriichi_Tsugikuni ( ɻɛɑ...
11 tháng 6 2021 lúc 14:55

Scratch hay java

Bình luận (0)
 Khách vãng lai đã xóa
Vương Thị Minh Tâm
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 1 2022 lúc 8:55

Bài 4: 

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

sort(a+1,a+n+1);

cout<<"So lon nhat la: "<<a[n]<<endl;

cout<<"So nho nhat la: "<<a[1]<<endl;

cout<<"So lon thu hai la: "<<a[n-1]<<endl;

cout<<"So nho thu hai la: "<<a[2];

return 0;

}

Bình luận (1)
Gia Bảo Lê
Xem chi tiết
Linh Đan
Xem chi tiết
Võ Đức Dũng
17 tháng 9 2021 lúc 21:33

câu 1

Program Nguyen_to;

Var n,i:integer;

Function NT(n:integer):Boolean;

Var ok: Boolean;

i: integer;

Begin ok:=true;

for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;

if n < 2 then NT:=false else NT:=ok;

End;

Begin Write('Nhap n: ');

Readln(n); i:=n;

Repeat i:=i+1;

Until NT(i);

Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);

Readln End.

Bình luận (1)
Võ Đức Dũng
17 tháng 9 2021 lúc 21:39

câu 2

uses crt;

const so: set of char=['0','1','2','3','4','5','6','7','8','9'];

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

st,b:string;

c,l,i,n,j:integer;

s, Max: integer;

begin clrscr;

write('Nhap xau:');

readln(st);

l:=length(st);

i:=1;

n:=0;

repeat if (st[i] in so) then begin b:=''

repeat b:=b+st[i];

inc(i);

until (not(st[i] in so)) or (i>l);

inc(n);

val(b,a[n],c);

end;

inc(i);

until i>l;

Max:=a[1];

for i:=2 to n do If Max<A[i] Then Max:=A[i];

Writeln('Phan tu lon nhat cua mang:', Max);

readln;

end.

Bình luận (0)
Yến Phạm
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 5 2022 lúc 10:24

uses crt;

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

i,n,t,ln,nn:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

ln:=a[1];

nn:=a[1];

t:=0;

for i:=1 to n do 

begin

if ln<a[i] then ln:=a[i];

if nn>a[i] then nn:=a[i];

t:=t+a[i];

end;

writeln(ln);

writeln(nn);

writeln(t);

for i:=1 to n do 

  if a[i] mod 2=0 then write(a[i]:4);

readln;

end.

Bình luận (0)
Bảo Nam
25 tháng 5 2022 lúc 15:36

var n,i,max,min,s: integer;

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

begin

readln(n);

for i:=1 to n do begin

readln(a[i]);

s:=s+a[i];

end;

max:=a[1]; min:=a[1];

for i:=2 to n do begin

if max<a[i] then max:=a[i];

if min>a[i] then min:=a[i];

end;

writeln('MAX=',max,'  | MIN=',min);

for i:=1 to n do if a[i] mod 2=0 then write(a[i],' '); writeln;

write('Tong = ',s);

readln

end.

Bình luận (0)