Những câu hỏi liên quan
Gin k4 FF
Xem chi tiết
Minh Thư
Xem chi tiết
Ngô Bá Hùng
15 tháng 4 2023 lúc 17:19

def sum_and_diff(m, n):
    sum = m + n
    diff = m - n
    return sum, diff

# sử dụng chương trình con
a = 5.6
b = 2.3
result = sum_and_diff(a, b)
print("Tổng và hiệu của", a, "và", b, "là", result)

Bình luận (0)
Kamato Heiji
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 3 2021 lúc 21:34

1:

uses crt;

var i,j,t,kt:integer;

begin

clrscr;

t:=0;

for i:=1 to 100 do 

  if i>1 then 

begin

kt:=0;

for j:=2 to i-1 do 

  if i mod j=0 then kt:=1;

if kt=0 then t:=t+i;

end;

writeln(t);

readln;

end.

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

Câu 2: 

*Viết chương trình:

uses crt;

var n,p,t:integer;

begin

clrscr;

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

t:=0;

for p:=2 to n-1 do 

  if n mod p=0 then t:=t+p;

writeln('Tong cac uoc that su cua ',n,' la: ',t);

readln;

end.

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

Dễ mà bạn tự làm đi

Bình luận (0)
 Khách vãng lai đã xóa
32.Thuỳ 7/2
Xem chi tiết
Nguyễn Hoàng Duy
13 tháng 3 2023 lúc 22:56

1.

Var i ,n : integer;

S , T : real;

Begin

Write ('n:') ;

Read (n) ;

S:= 0;

T:= 1;

For i:= 1 to n do

S:= S + i;

T:= T * i;

Writeln (' Tong cua ' ,n,' , S );

Writeln (' Tich của ' ,n,', T );

Readln;

End.

Bình luận (0)
Nguyễn Hoàng Duy
13 tháng 3 2023 lúc 23:02

2.

program SumAndProductOfNumbers;

var
  n, m, i, sum, product: integer;

begin
  writeln('Enter the values of n and m: ');
  readln(n, m);
  
  sum := 0;
  product := 1;
  
  for i := n to m do
  begin
    sum := sum + i;
    product := product * i;
  end;
  
  writeln('The sum of numbers from ', n, ' to ', m, ' is: ', sum);
  writeln('The product of numbers from ', n, ' to ', m, ' is: ', product);
end.

Bình luận (0)
Nguyễn Hoàng Duy
13 tháng 3 2023 lúc 23:03

3.

program SumAndProductOfNumbers;

var
  i, sum, product: integer;

begin
  sum := 0;
  product := 1;
  
  for i := 10 to 25 do
  begin
    sum := sum + i;
    product := product * i;
  end;
  
  writeln('The sum of numbers from 10 to 25 is: ', sum);
  writeln('The product of numbers from 10 to 25 is: ', product);
end.

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

Câu 1: 

uses crt;

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

i,n:integer;

t:real;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=0;

for i:=1 to n do 

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

writeln(t:4:2);

readln;

end.

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

Câu 2: 

uses crt;

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

i,n:integer;

t:real;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=1;

for i:=1 to n do 

  t:=t*a[i];

writeln(t:4:2);

readln;

end.

Bình luận (0)
Sơn Tùng MTP
Xem chi tiết
nguyễn phạm phương dung
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 12 2022 lúc 0:33

uses crt;

var n,i,t:integer;

begin

clrscr;

readln(n);

t:=0;

for i:=1 to n-1 do

if i mod 2=0 then

begin

write(i:4);

t:=t+i;

end;

writeln;

writeln(t);

readln;

end.

Bình luận (0)
Nguyễn Hoàng Anh
14 tháng 3 2023 lúc 13:42

n = int(input())
s = 0
for i in range(1, n):
    if i % 2 == 0:
        print(i)
        s += i
print(s)

Bình luận (0)
Lâm Khả Doanh
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 2 2023 lúc 22:28

1:

uses crt;

var n,i,t:integer;

begin

clrscr;

readln(n);

t:=0;

for i:=1 to n do

t:=t+i*i;

write(t);

readln;

end.

Bình luận (0)
Lê Chiêu Nguyên	Vũ
4 tháng 4 2023 lúc 10:21

2

program bt2;

var i,n,t:integer;

begin

readln(n);

s:=0;

for i:=1 to n do

if i mod 2 = 1 then s:=s+i;

readln;

end.

Bình luận (0)
NGUYỄN LÊ XUÂN THỊNH
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 2 2023 lúc 0:38

Câu 6:

uses crt;

var n,i:integer;

begin

clrscr;

readln(n);

for i:=1 to n do 

if n mod i=0 then write(i:4);

readln;

end.

5:

uses crt;

var n,i,dem:integer;

begin

clrscr;

readln(n);

dem:=0;

for i:=0 to n do

if i mod 2=1 then 

begin

write(i:4);

dem:=dem+1;

end;

writeln;

writeln(dem);

readln;

end.

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

Bài 1: 

uses crt;

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

i,n:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

for i:=1 to n do 

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

readln;

end.

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

Bài 2: 

uses crt;

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

i,n:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

for i:=1 to n do

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

readln;

end.

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

Bài 3: 

uses crt;

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

i,n,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=0;

for i:=1 to n do 

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

writeln(t);

readln;

end.

Bình luận (0)