Những câu hỏi liên quan
Hoàng Trần Thanh Hà _THP...
Xem chi tiết
gấu béo
26 tháng 3 2023 lúc 22:37

n = int(input("Nhập n: "))

a = [ ]

for i in range(n):

     a.append(int(input(f"Nhập phần tử a[{i}]: ")))

print("Dãy số vừa nhập:")

# In dãy số theo thứ tự ngược lại

print(a[::-1]) 

if a == a[::-1]:

     print("Dãy số là dãy đối xứng")

else:

     print("Dãy số không phải là dãy đối xứng")

Bình luận (0)
Vu Hoang Anh
Xem chi tiết

#include <bits/stdc++.h>
using namespace std;
bool ktsnt(long long n)
{
    long long i;
if(n<2) return false;
    else
    {
        for(i=2;i<=sqrt(n);i++)
            if(n%i==0)
            return false;
        return true;
    }
}
long long cnt;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>cnt;
if(ktsnt(cnt)==true)
    cout<<"YES";
else
    cout<<"NO";
return 0;
}

 

Bình luận (0)
Kiều Vũ Linh
10 tháng 2 2022 lúc 16:23

var i,n,dem:integer;

begin

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

for i:=1 to n do

begin

if n mod i = 0 then dem:=dem+1;

end;

if dem = 2 then write(n,' la so nguyen to')

else write(n,' khong la so nguyen to');

readln;

end.

 

Bình luận (0)
Quỳnh Chi Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 1 2021 lúc 13:54

uses crt;

var a,x:longint;

{------------------ham-kiem-tra-so-nguyen-to---------------}

function ktnt(x:longint):boolean;

var kt:boolean;   

i:longint;

begin   

kt:=true;   

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

if x mod i=0 then       

begin           

kt:=false;           

break;       

end;   

if kt=true then ktnt:=true   

else ktnt:=false;

end;

{---------------chuong-trinh-chinh-------------------}

begin

clrscr;

repeat 

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

until a>10;

if ktnt(a)=true then   

begin     

x:=a;     

repeat         

a:=a div 10;         

if ktnt(a)=true then a:=a div 10;     

until a<10;     

if (ktnt(a)=true) and (a>1) then writeln(x,' la so sieu nguyen to')     

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

end

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

readln;

end.

Bình luận (0)

bn ơi cấu hỏi hơi bị khó hiểu xíu 

Bình luận (0)
Dân Phạm Văn
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 21:20

Bài 1: 

uses crt;

var n,i,kt:integer;

begin

clrscr;

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

kt:=0;

for i:=2 to n-1 do 

 if n mod i=0 then kt:=1;

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

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

readln;

end.

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

Bài 2: 

uses crt;

var n,i:integer;

begin

clrscr;

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

for i:=1 to n do 

 if n mod i=0 then write(i:4);

readln;

end.

Bình luận (0)
Lala
Xem chi tiết
TTTheGodd
Xem chi tiết
Thế Long
Xem chi tiết
Luân Đào
1 tháng 1 2021 lúc 15:59

var n,i,k,d: integer;

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

begin

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

for i:=1 to n do

begin

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

end;

write('Nhap so k: '); readln(k);

d:=0;

for i:=1 to n do

if a[i] mod k = 0 then d:=d+1;

writeln('Co ',d,' so chia het cho ',k,' trong day');

if d mod 2 = 0 then writeln('Chan') else writeln('Le');

end.

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

uses crt;

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

i,n,k,dem:integer;

begin

clrscr;

repeat

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

until (0<n) and (n<=52);

for i:=1 to n do 

  begin

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

end;

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

dem:=0;

for i:=1 to n do  

  if a[i] mod k=0 then inc(dem);

writeln('Trong day co ',dem,' so chia het cho ',k);

if dem mod 2=0 then writeln('So luong so chia het cho ',k,' la so chan')

else writeln('So luong so chia het cho ',k,' la so le');

readln;

end.

Bình luận (0)
Nguyễn Yến Trang
Xem chi tiết
Nguyễn Lê Phước Thịnh
1 tháng 3 2022 lúc 14:47

Bài 1:

#include <bits/stdc++.h>

using namespace std;

long long n,i;

bool kt;

int main()

{

cin>>n;

if (n>1) 

{

kt=true;

for (i=2; i*i<=n; i++) 

if (n%i==0) kt=false;

if (kt==true) cout<<n<<" la so nguyen to";

else cout<<n<<" khong la so nguyen to";

}

else cout<<n<<" khong la so nguyen to";

return 0;

}

 

Bình luận (0)
Đỗ Trọng TÍn
Xem chi tiết