Những câu hỏi liên quan
Hiền Nguyễn
Xem chi tiết
Hiền Nguyễn
24 tháng 3 2021 lúc 9:08

Bạn ơi giúp mình với chiều nay mình thi rồi

 

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

Câu 2: 

uses crt;

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

i,n,tb:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

tb:=0;

for i:=1 to n do 

  tb:=tb+a[i];

writeln(tb/n:4:2);

readln;

end.

Bình luận (0)
Tuấn Trần thị
Xem chi tiết
Kiều Vũ Linh
10 tháng 5 2023 lúc 17:46

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

i,n,max:integer;

Begin

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

For i:=1 to n do

Begin

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

End;

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

For i:=1 to n do 

Write(a[i]:8);

writeln;

max:=a[1];

For i:=2 to n do

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

write('So lon nhat la ',max);

Readln

End.

Bình luận (0)
Yeu DUong nhat
Xem chi tiết
Minh Lệ
17 tháng 5 2021 lúc 21:57

Program HOC24;

var n,d,i: integer;

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

t: longint;

begin

write('Nhap N: '); readln(n);

for i:=1 to n do 

begin

write('B[',i,']='); readln(b[i]);

end;

d:=0; t:=0;

for i:=1 to n do 

if b[i]>0 then

begin

d:=d+1;

t:=t+b[i];

end;

writeln('Tong cac so duong trong day so la: ',t);

write('Co ',d,' so duong trong day');

readln

end.

Bình luận (0)
Lê Thị Thu Phương
7 tháng 6 2021 lúc 21:22

uses crt;
var b:array[1..100] of longint;
      n,i,d,s:longint;
begin
      clrscr;
      write('n='); readln(n);
      for i:=1 to n do 
            begin
                  write('a[',i,']: '); readln(b[i]);
                  if b[i]>0 then begin
                        inc(d);
                        inc(s,b[i]);
                  end;
            end;
      writeln('Tong cac so duong: ',s);
      writeln('Co ',d,' so duong');
      readln;
end.

Bình luận (0)
Quỳnh
Xem chi tiết
Minh Lệ
29 tháng 4 2021 lúc 14:33

Program HOC24;

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

i,n,d: integer;

begin

write('Nhap N: ');

for i:=1 to n do

begin

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

end;

write('Day vua nhap la: '); 

for i:=1 to n do write(a[i],' '); writeln;

d:=0;

for i:=1 to n do if a[i]>0 then d:=d+1;

write('Co ',d,' so duong');

readln

end.

Bình luận (0)
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.

Bình luận (0)
Quân Đoàn Long Tường
Xem chi tiết
Thành Phạm
26 tháng 4 2023 lúc 10:20

Python:
n = input("Nhập dãy số nguyên: ").split()
n = [int(i) for i in n]

so_le = [i for i in n if i % 2 != 0]
tong = sum(n)

print("Các số lẻ trong dãy là: ", so_le)
print("Tổng các số trong dãy là: ", tong)

Pascal:

program tongvasole;

const
  MAX_SIZE = 1000;

var
  numbers: array[1..MAX_SIZE] of Integer;
  count, i: Integer;
  total: Integer;
begin
  Write('Nhập số lượng phần tử trong dãy: ');
  ReadLn(count);
  for i := 1 to count do
  begin
    Write('Nhập phần tử thứ ', i, ': ');
    ReadLn(numbers[i]);
  end;

  Write('Các số lẻ trong dãy là: ');
  total := 0;
  for i := 1 to count do
  begin
    if numbers[i] mod 2 <> 0 then
      Write(numbers[i], ' ');
    total := total + numbers[i];
  end;
  WriteLn;

  WriteLn('Tổng các số trong dãy là: ', total);
end.

Bình luận (0)
Nguyễn minh quân
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 2 2021 lúc 18:09

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)
ひまわり(In my personal...
20 tháng 2 2021 lúc 17:17

#include <stdio.h>

#include <conio.h>

#include <math.h>

int main()

{

int n,i,x[10];

printf("nhap so luong phan tu");

scanf("%d",&n);

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

{

printf("x[%d]",i);

scanf("%d",&x[i]);

}

printf("mang x[i] da nhap vap");

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

{

printf("%2d",x[i]);

} for(i=0;i<n;i++)

{

if(nt(x[i],n)==1)

{

printf("cac so nguyen to co trong mang la %d",x[i]);

}

}

}

int nt(int x[10],int n)

{

int i,j;

int kt;

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

{

kt=1;

 for(j=2;j<x[i];j++)

{

if(x[i]%j==0) kt=0;

}

}

if(kt)

{

return 1;

}

else

{

return 0;

}

}

Bình luận (0)
Phạm Linh
Xem chi tiết
Minh Lệ
2 tháng 5 2023 lúc 21:28

Program HOC24;

var i,n: integer;

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

begin

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]>5 then write(a[i],' ');

readln

end.

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

uses crt;

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

i,n,h:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

h:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then h:=h-a[i];

writeln(h);

readln;

end.

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

uses crt;

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

i,n,t:integer;

begin

clrscr;

readln(n);

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

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

writeln;

t:=0;

for i:=1 to n do 

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

writeln(t);

readln;

end.

Bình luận (1)