K
Khách

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.

11 tháng 12 2021

4:

#include <bits/stdc++.h>

using namespace std;

long long a;

int main()

{

cin>>a;

if (a%2==0) cout<<"Chan";

else cout<<"Le";

return 0;

}

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.

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.

25 tháng 12 2023

câu 1:
 

program AlgorithmExample;

var
  T, n: integer;

begin
  // Bước 1
  T := 8;
  n := 1;

  // Bước 2
  while T < 99 do
  begin
    // Bước 3
    n := n + 3;
    T := T * n;
  end;

  // Bước 4
  writeln('Gia tri cua T: ', T);
  writeln('Gia tri cua n: ', n);

  readln;
end.
câu 2:
 

program StudentAverage;

var
  n, countAboveAverage: integer;
  sum, average, score: real;

begin
  // Nhập số lượng học sinh
  write('Nhap so luong hoc sinh (1-70): ');
  readln(n);

  // Kiểm tra điều kiện
  if (n < 1) or (n > 70) then
  begin
    writeln('So luong hoc sinh khong hop le.');
    readln;
    halt;
  end;

  // Khởi tạo biến
  countAboveAverage := 0;
  sum := 0;

  // Nhập và tính điểm trung bình
  for var i := 1 to n do
  begin
    write('Nhap diem cua hoc sinh ', i, ': ');
    readln(score);
    sum := sum + score;

    // Kiểm tra điều kiện điểm trung bình
    if score >= 5.0 then
      countAboveAverage := countAboveAverage + 1;
  end;

  // Tính điểm trung bình
  average := sum / n;

  // In ra kết quả
  writeln('So luong hoc sinh dat diem trung binh tro len: ', countAboveAverage);
  writeln('Ti le hoc sinh dat diem trung binh tro len: ', countAboveAverage / n * 100:0:2, '%');

  readln;
end.
Lưu ý rằng trong chương trình của câu 2, điểm trung bình được tính và sau đó kiểm tra xem học sinh có đạt điểm
trung bình trở lên hay không.

 

 

a: uses crt;

var i,n:integer;

s:real;

begin

clrscr;

s:=0;

for i:=1 to 100 do s:=s+1/i;

writeln(s:4:2);

readln;

end.

b: 

uses crt;

var i,n:integer;

s:real;

begin

clrscr;

s:=0;

i:=0;

while i<=100 do 

begin

inc(i);

s:=s+1/i;

end;

writeln(s:4:2);

readln;

end.

uses crt;

var n,s:integer;

begin

clrscr;

s:=0;

n:=0;

while s<=1000 do 

  begin

n:=n+1;

s:=s+n;

end;

writeln(s);

writeln(n);

readln;

end.

a: Thuật toán sẽ thực hiện 5 vòng lặp

Kết thúc thì S=0

b: uses crt;

var i,s,n:integer;

begin

clrscr;

s:=20;

n:=1;

while (s>=5) do 

begin

n:=n+1;

s:=s-n;

end;

writeln(s);

readln;

end.

uses crt;

var s,n:integer;

begin

clrscr;

s:=20;

n:=1;

while s>=5 do 

begin

n:=n+1;

s:=s-n;

end;

writeln(s);

readln;

end.

Thuật toán sẽ chạy 5 vòng lặp

Kết thúc thì S=0