Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
Nguyễn Thị Ngọc Oanh
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 1 2022 lúc 21:55

#include <bits/stdc++.h>

using namespace std;

long long dem,x,n,i,t;

int main()

{

cin>>n;

t=0;

dem=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0)

{

dem++;

t+=x;

}

}

cout<<dem<<" "<<t;

return 0;

}

Kiều Vũ Linh
22 tháng 1 2022 lúc 8:00

Var s,n,i,dem,so:integer;

Begin

Write('Nhap so luong so n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i);readln(so);

If so mod 2 = 0 then

Begin

dem:=dem+1;

s:=s+so;

End;

End;

Writeln('Co ',dem,' so chan');

Write('Tong cac so chan la ',s);

Readln;

End.

Dragon dratie
Xem chi tiết
Nguyễn Đức Hoàn
Xem chi tiết
Nguyễn Văn Tùng
5 tháng 5 2023 lúc 20:45

Đây là code Pascal để nhập và in điểm kiểm tra học kì môn tin cho N của từng học sinh:

program DiemKT;

var
N, i: integer;
diem: array1..100 of integer;

begin
write('Nhap so hoc sinh: ');
readln(N);

for i := 1 to N do
begin
write('Nhap diem kiem tra hoc ki cua hoc sinh thu ', i, ': ');
readln(diemi);
end;

writeln('Diem kiem tra hoc ki cua ', N, ' hoc sinh la:');

for i := 1 to N do
writeln('Hoc sinh thu ', i, ': ', diemi);

end.

quân nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 4 2022 lúc 21:42

a: 

#include <bits/stdc++.h>

using namespace std;

double a[1000];

int n,i;

int main()

{

cin>>n;

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

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

b: 

#include <bits/stdc++.h>

using namespace std;

long long a[50],n,i,t;

int main()

{

cin>>n;

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

t=0;

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

cout<<t;

return 0;

}

Lê Nguyễn Ánh Nguyệt
Xem chi tiết
Ngô Bá Hùng
25 tháng 4 2023 lúc 23:32

program DiemKiemTra;
var
  i, max: integer;
  diem: array[1..30] of integer; 

begin
  for i := 1 to 30 do
  begin
    writeln('Nhap diem cua hs thu ', i, ': ');
    readln(diem[i]);
  end;
  max := diem[1];
  for i := 2 to 30 do
  begin
    if diem[i] > max then
      max := diem[i];
  end;
  writeln('Diem cao nhat la: ', max);
end.

42. Hồ Đăng Quốc Trung....
Xem chi tiết
Kim Kiều
Xem chi tiết
Nguyen Hung
3 tháng 5 2021 lúc 21:00

Uses crt;

Var i,n:integer;

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

Begin

clrscr;

Write('Nhap so hoc sinh: ');readln(n);

Writeln('Nhap diem hoc ki mon tin cua ',n,' em hoc sinh:');

For i:=1 to n do

Begin

Write('Hoc sinh thu ',i,' : ');

readln(a[i]);

End;

Writeln('Diem kiem tra cua ',n,' em hoc sinh vua nhap la:');

For i:= 1 to n do writeln('Hoc sinh thu ',i,' : ',a[i]);

readln;

End.

Tuấn Trần thị
Xem chi tiết
Kiều Vũ Linh
10 tháng 5 2023 lúc 17:41

Var a:array:[1..50] of real;

i,max:integer;

Begin

For i:=1 to 50 do

Begin

Write('Nhap so thu ',i,' = ');readln(a[i]);

End;

Write('Cac diem vua nhap la: ');

For i:=1 to 50 do 

Write(a[i]:10:2);

Writeln;

max:=a[1];

For i:=2 to 50 do

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

Write('Diem trung binh lon nhat la ',max:10:2);

Readln

End.

Kiều Vũ Linh
10 tháng 5 2023 lúc 17:44

Var a:array:[1..50] of real;

i:integer;

max:real;

Begin

For i:=1 to 50 do

Begin

Write('Nhap diem thu ',i,' = ');readln(a[i]);

End;

Write('Cac diem vua nhap la: ');

For i:=1 to 50 do 

Write(a[i]:10:2);

writeln;

max:=a[1];

For i:=2 to 50 do

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

write('Diem lon nhat la ',max:10:2);

Readln

End.

Nguyễn Trần Hồng Ngọc
Xem chi tiết
Phía sau một cô gái
7 tháng 5 2023 lúc 20:02

program TinhTBCTimSoNT;

var
  ten, lop: string;
  n, i, tong, dem: integer;
  A: array [1..11] of integer;
  trung_binh: real;

function LaSoNguyenTo(x: integer): boolean;
var
  i: integer;
begin
  if x < 2 then
    LaSoNguyenTo := false
  else if x = 2 then
    LaSoNguyenTo := true
  else if x mod 2 = 0 then
    LaSoNguyenTo := false
  else
  begin
    i := 3;
    while (i <= trunc(sqrt(x))) and (x mod i <> 0) do
      i := i + 2;
    LaSoNguyenTo := x mod i <> 0;
  end;
end;

begin
  // Nhập tên và lớp của học sinh
  write('Nhập tên của học sinh: ');
  readln(ten);
  write('Nhập lớp: ');
  readln(lop);

  // Nhập dãy số nguyên và tính trung bình cộng
  repeat
    write('Nhập số phần tử của dãy số (n<12): ');
    readln(n);
  until n < 12;
  tong := 0;
  for i := 1 to n do
  begin
    write('Nhập phần tử thứ ', i, ': ');
    readln(A[i]);
    tong := tong + A[i];
  end;
  trung_binh := tong / n;

  // In tên, lớp, dãy số và trung bình cộng ra màn hình
  writeln('Học sinh: ', ten);
  writeln('Lớp: ', lop);
  write('Dãy số: ');
  for i := 1 to n do
    write(A[i], ' ');
  writeln;
 
  // In các số nguyên tố của dãy số ra màn hình
  writeln('Các số nguyên tố của dãy số:');
  for i := 1 to n do
    if LaSoNguyenTo(A[i]) then
      writeln(A[i]);
end.