Những câu hỏi liên quan
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 1 2021 lúc 22:42

uses crt;

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

i,n,t,t1,t2,t3,min,max:integer;   

kt:boolean;

begin

clrscr;

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

for i:=1 to n do 

begin     

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

end;

writeln('Day so ban vua nhap la: ');

for i:=1 to n do 

write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

t:=t+a[i];

kt:=true;

for i:=2 to trunc(sqrt(t)) do 

if t mod i=0 then     

begin       

kt:=false;       

break;     

end;

writeln('Tong cua day so la: ',t);

if (kt=true) and (t>1) then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

writeln('Cac so o vi tri le cua day so la: ');

t1:=0;

for i:=1 to n do 

if i mod 2=1 then     

begin       

write(a[i]:4);       

t1:=t1+a[i];     

end;

writeln;

writeln('Tong cac so o vi tri le cua day so la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

writeln('Cac so o vi tri chan cua day so la: ');

t2:=0;

for i:=1 to n do 

if i mod 2=0 then     

begin       

write(a[i]:4);       

t2:=t2+a[i];     

end;

writeln;

writeln('Tong cac so o vi tri chan cua day so la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if t3=t2 then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to n do 

begin     

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

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

end;

writeln('So lon nhat cua day la: ',max);

writeln('So nho nhat cua day la: ',min);

writeln('Tong cua so lon nhat va so nho nhat la: ',max+min);

readln;

end.

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

uses crt;

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

n,i,t,kt,j,t1,t2,t3,max,min:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

writeln('Day so ban vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln('Tong cua day so vua nhap la: ',t);

kt:=0;

for i:=2 to trunc(sqrt(t)) do 

  if t mod i=0 then

begin

kt:=1;

break;

end;

if (kt=0) and (t>1) then writeln(t,' la so nguyen to');

else writeln(t,' khong la so nguyen to');

t1:=0;

writeln('Cac so o vi tri le cua day la: ');

for i:=1 to n do 

  if i mod 2=1 then 

begin

write(a[i]:4);

t1:=t1+a[i];

end;

writeln;

writeln('Tong cac so o vi tri le la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

t2:=0;

writeln('Cac so o vi tri chan la: ');

for i:=1 to n do 

  if i mod 2=0 then 

begin

write(a[i]:4);

t2:=t2+a[i];

end;

writeln;

writeln('Tong cac so o vi tri chan la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if t3=t2 then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to n do 

begin

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

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

end;

writeln('Gia tri lon nhat la: ',max);

writeln('Gia tri nho nhat la: ',min);

writeln('Tong cua hai so lon nhat va nho nhat la: ',max+min);

readln;

end.

Bình luận (1)
hoàng kim
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 23:25

Bài 1: 

uses crt;

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

i,n,min:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

min:=a[1];

for i:=1 to n do 

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

writeln(min);

readln;

end.

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

Bài 2: 

uses crt;

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

i,n,max:integer;

begin

clrscr;

write('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 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)
lanh nguyen
Xem chi tiết
lanh nguyen
9 tháng 5 2022 lúc 19:28

tl nhanh giúp mình ạ:(

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

#include <bits/stdc++.h>

using namespace std;

long long a[1000],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ì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)
su nè
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 4 2022 lúc 22:02

#include <bits/stdc++.h>

using namespace std;

long long a[100],i,n;

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ình luận (0)
ngô bá hiếu
Xem chi tiết
Kiều Vũ Linh
1 tháng 5 2023 lúc 18:38

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

s:longint;

i,n:integer;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

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

If a[i] > 0 then s:=s+a[i];

End;

Write('Tong la ',s);

Readln

End.

Bình luận (0)
Nguyễn Ngọc Thiện Nhân
1 tháng 5 2023 lúc 10:16

Bình luận (3)
 ohsusu
Xem chi tiết
Minh Lệ
30 tháng 4 2021 lúc 16:32

Program HOC24;

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

i,max,,n: integer;

begin

write('Nhap so phan tu 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 a[i]<max then max:=a[i];

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

readln

end.

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

uses crt;
var a:array[1..1000000] of longint;
      n,i,max:longint;
begin
      clrscr;
      write('Nhap so luong phan tu: '); readln(n);
      max:=a[1];
      for i:=1 to n do 
            begin
                  write('Nhap phan tu thu ',i,': '); readln(a[i]);
                  if a[i]>max then max:=a[i];
            end;
      writeln('GTLN: ',max);
      readln;
end.

Bình luận (0)
Nguyễn Khải Minh
Xem chi tiết
Kiều Vũ Linh
30 tháng 4 2022 lúc 7:22

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

i,s:integer;

Begin

I:=1;

While i<=15 do

Begin

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

s:=s+a[i];

i:=i+1;

End;

Write('Tong la ',s);

Readln;

End.

Bình luận (0)