Những câu hỏi liên quan
mistud
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 12 2021 lúc 23:17

2:

#include <bits/stdc++.h>

using namespace std;

long long n,i;

int main()

{

cin>>n;

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

if (n%i==0) cout<<i<<" ";

return 0;

}

Bình luận (0)
Nguyễn Văn Ý
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 4 2021 lúc 20:39

uses crt;

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

i,n,t,k:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

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

t:=0;

for i:=1 to n do 

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

writeln(t);

readln;

end.

Bình luận (1)
Trần Thị Mai Ngọc
Xem chi tiết
nguyễn an phát
18 tháng 4 2021 lúc 20:48

program tim_uoc;

uses crt;

var i,n,tong:integer;

begin

clrscr;

write('nhap so n:');readln(n);

i:=1;tong:=0;

writeln('cac uoc cua ',n,' la:');

while i<=n do

if n mod i=0 then

begin

write(i:3);

inc(i);

end;

writeln;

i:=1;writeln('cac uoc chan:');

while i<=n do

begin

if n mod i=0 then 

begin

if i mod 2=0 then write(i:3);

tong:=tong+i;

end;

end;

writeln;

write('tong cac uoc chan:',tong);

readln;

end.

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

uses crt;

var n,i,t:integer;

begin

clrscr;

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

i:=1;

writeln('Cac uoc cua ',n,' la: ');

while i<=n do

  begin

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

i:=i+1;

end;

writeln;

writeln('Cac uoc chan cua ',n,' la: ');

t:=0;

i:=1;

while i<=n do 

  begin

if (n mod i=0) then

begin

t:=t+i;

write(i:4);

end;

inc(i);

end;

writeln('Tong cac uoc chan cua ',n,' la: ',t);

readln;

end.

Bình luận (0)
Nguyễn Phú Trọng
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 12 2020 lúc 22:28

uses crt;

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

 n,i,max,min,dem,t,dem1,t1,dem2,t2,dem3,t3,dem4,t4,k:integer;

begin

clrscr;

write('Nhap 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('So lon nhat trong day la: ',max);

dem:=0;

t:=0;

for i:=1 to n do 

if max=a[i] then     

begin       

inc(dem);

t:=t+a[i];       

vtmax[dem]:=i;     

end;

if dem>1 then   

begin     

writeln('Tong cac so max la: ',t);     

writeln('Cac vi tri co so max la: ');     

for i:=1 to dem do       

write(vtmax[i]:4);   

end;

min:=a[1];

for i:=1 to n do 

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

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

dem1:=0;

t1:=0;

for i:=1 to n do 

if min=a[i] then     

begin       

inc(dem1);       

t1:=t1+a[i];       

vtmin[dem1]:=i;     

end;

if dem1>1 then   

begin     

writeln('Tong cac so min la: ',t1);     

writeln('Cac vi tri co so min la: ');     

for i:=1 to dem1 do       

write(vtmin[i]:4);   

end;

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

dem2:=0;

t2:=0;

for i:=1 to n do 

if (i mod 2=0) and (a[i] mod k=0) then     

begin       

dem2:=dem2+1;       

t2:=t2+a[i];     

end;

writeln('So phan tu o vi tri chan trong day la boi cua ',k,' la: ',dem2);

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

dem3:=0;

t3:=0;

for i:=1 to n do 

if (i mod 2=1) and (k mod a[i]=0) then     

begin       

inc(dem3);       

t3:=t3+a[i];     

end;

writeln('So phan tu o vi tri le trong day la uoc cua ',k,' la: ',dem3);

writeln('Tong cac so o vi tri le trong day la uoc cua ',k,' la: ',t3);

dem4:=0;

t4:=0;

for i:=1 to n do 

if (a[i]+k=1) or (a[i]=k+1) then     

begin       

inc(dem4);       

t4:=t4+a[i];     

end;

writeln('So phan tu la anh em cua ',k,' trong day la: ',dem4);

writeln('Tong cac phan tu la anh em cua ',k,' trong day la: ',t4);

readln;

end.

Bình luận (0)
Hoàng Thị Vân Anh
Xem chi tiết

N có giới hạn ko ạ

Bình luận (0)
Hoà Trần
Xem chi tiết
Hoà Trần
6 tháng 10 2021 lúc 22:50

Ai giải giúp mik đi ạ đag hok thj bị cô gọi lên bảng ko bt lm như thek nào mn giúp mik vs ạ 😭😭😭😭

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

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n,i;

cin>>n;

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

if (n%i==0) cout<<i<<" ";

return 0;

}

Bình luận (0)
Phạm Gia Bình
Xem chi tiết
Minh Lệ
24 tháng 8 2021 lúc 21:12

Program HOC24;

var d,i,n: integer;

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

begin

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

for i:=1 to n do

begin 

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

end;

write('Cac phan tu cua mang vua nhap la: ');

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

writeln;

d:=0;

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

writeln('Co ',d,' phan tu co gia tri la uoc cua 10');

write('Cac phan tu o vi tri chan la: ');

for i:=1 to n do if i mod 2=0 then write(a[i],' ');

writeln;

write('Cac phan tu o vi tri le la: ');

for i:=1 to n do if i mod 2=1 then write(a[i],' ');

readln

end.

Bình luận (0)
Selena Flynn
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 23:03

c1: 

#include <bits/stdc++.h>

using namespace std;

long long i,n,s;

int main()

{

cin>>n;

s=1;

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

cout<<s;

return 0;

}

Câu 2: 

#include <bits/stdc++.h>

using namespace std;

long long i,n,s;

int main()

{

cin>>n;

s=1;

for (i=1; i<=n; i++) if (i%2==0) s=s*i;

cout<<s;

return 0;

}

Bình luận (0)
Trí Nguyễn
Xem chi tiết
Phía sau một cô gái
7 tháng 7 2023 lúc 20:19

program bai_toan;

var

      N, i, sum: integer;

begin

      write('Nhap so N: ');

      readln(N);

      write('Cac uoc cua ', N, ' khong ke ', N, ' la: ');

      for i := 1 to N - 1 do

            if N mod i = 0 then

                  write(i, ' ');

      writeln;

      sum := 0;

      for i := 1 to N - 1 do

      begin

            if N mod i = 0 then sum := sum + i;

      end;

      if sum = N then writeln(N, ' la so hoan hao')

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

      writeln;

      writeln('Tat ca so hoan hao trong pham vi 1 -> ', N, ' la:');

      for i := 1 to N do

      begin

            sum := 0;

            for j := 1 to i - 1 do

            begin

                  if i mod j = 0 then sum := sum + j;

            end;

            if sum = i then writeln(i);

      end;

      readln;

end.

Bình luận (0)