Những câu hỏi liên quan
Phạm Thị Kim Anh
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 4 2022 lúc 17:09

uses crt;

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

i,n,t,kt,j:integer;

begin

clrscr;

readln(n);

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

t:=0;

for i:=1 to n do 

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

writeln(t);

for i:=1 to n do 

  if trunc(sqrt(a[i]))=sqrt(a[i]) then write(a[i]:4);

writeln;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then kt:=1;

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

end;

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)
Ngọc Ty
Xem chi tiết
Kiều Vũ Linh
24 tháng 4 2023 lúc 18:56

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

i,n:integer;

s:longint;

Begin

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

For i:=1 to n do

Begin

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

s:=s+a[i];

End;

Write('Cac phan tu vua nhap la ');

For i:=1 to n do

Write(a[i]:8);

Writeln;

Write('Tong cua chung la ',s);

Readln

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:11

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)
Lưu Quang Trường
20 tháng 2 2021 lúc 16:19

uses crt;

var i,n: integer;

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

begin

writeln('nhap so nguyen n: '); readln(n);

for i:=1 to n do

begin

writeln('A[',i,']'); readln(a[i]);

if i mod 2 <>0 then writeln(i);

end;

readln;

end.

Bình luận (5)
bùi bình
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 3 2022 lúc 23:21

#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];

cout<<"Cac so le la: "<<endl;

for (i=1; i<=n; i++) if (a[i]%2!=0) cout<<a[i]<<" ";

cout<<endl;

cout<<"Cac so chan la: "<<endl;

for (i=1; i<=n; i++) if (a[i]%2==0) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Nguyễn Hoàng Duy
29 tháng 3 2023 lúc 15:32

n = int(input("Nhập vào giá trị của n: "))
even_count = 0
odd_count = 0

for i in range(1, n+1):
    if i % 2 == 0:
        even_count += 1
    else:
        odd_count += 1

print("Số chẵn trong dãy là:", even_count)
print("Số lẻ trong dãy là:", odd_count)

Bình luận (0)
Ngáo Ngơ Alice
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 3 2021 lúc 20:50

Bài 1: 

uses crt;

var n,i:integer;

s:real;

begin

clrscr;

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

s:=0;

for i:=1 to n do 

  s:=s+1/(2*i+1);

writeln(s:4:2);

readln;

end.

Bình luận (0)
KenShi
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 12 2021 lúc 0:39

Bài 2: 

#include <bits/stdc++.h>

using namespace std;

long long x,y;

int main()

{

cin >>x>>y;

cout<<x<<" "<<y;

swap(x,y);

cout<<x<<" "<<y;

return 0;

}

Bình luận (0)
Huệ anh •01•86
Xem chi tiết
Kiều Vũ Linh
17 tháng 3 2022 lúc 9:04

Var i,n:integer;

E:real;

Begin

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

E:=1;

For i:=2 to n do

Begin

E:=E*i;

i:=i+2;

End;

Write('E = ',E:15:0);

Readln;

End.

Bình luận (0)
Lê Tâm Anh
Xem chi tiết
gấu béo
7 tháng 5 2023 lúc 19:20

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

Bình luận (0)