K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

freopen("dayd.inp","r",stdin);

freopen("dayd.out","w",stdout);

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

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

if (a[i]>0) cout<<a[i]<<" ";

return 0;

}

3 tháng 11 2023

#include <bits/stdc++.h>

using namespace std;

int main () { int a[1000],n,i;

cin >> n;

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

cin >> a[i];

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

if (((a[i]<0) and (a[i-1]<0)) or ((a[i]>0) and (a[i-1]>0))) {

cout << a[i-1] <<" " << a[i];

break; }

return 0;

}

22 tháng 7 2023

program tong_so_le;

var

     n, i, a_i, tong: integer;

begin

     writeln('Nhap vao so nguyen khong am n:');

     readln(n);

     while (n <= 0) or (n > 100) do

     begin

          writeln('So nguyen n phai thoa man 0 < n <= 100, vui long nhap lai:');

          readln(n);

     end;

     writeln('Nhap vao ', n, ' so nguyen a1, a2, ..., an:','<mỗi số nguyên nhập trên một hàng>');

     tong := 0; // Khởi tạo tổng bằng 0

     for i := 1 to n do

     begin

          readln(a_i);

          if i mod 2 = 1 then

               tong := tong + a_i; 

     end;

     writeln('Tong cac so tai vi tri le trong mang la: ', tong);

end.

31 tháng 10 2021

Bài 2: 

#include <bits/stdc++.h>
using namespace std;
long long n,i;
//chuongtrinhcon
int demuoc(long long n)
{
    int dem=0;
    for (long long i=1; i<=n; i++)
        if (n%i==0) dem++;
    return (dem);
}
//chuongtrinhchinh
int main()
{
    freopen("tamuoc.inp","r",stdin);
    freopen("tamuoc.out","w",stdout);
    cin>>n;
    long long dem=0;
    for (i=1; i<=n; i++)
        if (demuoc(i)==3) dem++;
    cout<<dem;
    return 0;
}

 

31 tháng 10 2021

1.

#include <bits/stdc++.h>

using namespace std;

int A,n,i;

int main()

{

cin>>n;

A=0;

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

A=A+1/i;

cout<<A;

Return 0;

}

7 tháng 1 2022

Số N (0<N<10 mũ 9)

7 tháng 1 2022

N = int(input())
A = 0
B = 0
So_uoc = 0
KQ = ""
for x in range(1, N):
    if (x%2==0) and (x%3==0):
        A += 1
    if (x>0) and (N%x==0):
        if (x>B):
            B = x
for i in range(1, N+1):
    if (N%i==0):
        So_uoc += 1
if (So_uoc == 2):
    KQ = "YES"
else:
    KQ = "NO"
print(A)
print(B)
print(len(str(N)))
print(KQ)

(Chẳng biết đúng không đâu bucminh)

12 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,t,dem,j;

int main()

{

cin>>n;

x=n;

t=0;

while (n>0)

{

t=t+n%10;

n=n/10;

}

cout<<t;

dem=0;

for (i=2; i<=x; i++)

{

bool kt=true;

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

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

if (kt==true) dem++;

}

cout<<dem;

return 0;

}

8 tháng 10 2020

Program HOC24;

const fi='Cau1.INP';

fo='Cau2.OUT';

var i,a,b,c,t,d: integer;

f: text;

function ucln(x,y: integer): integer;

var t: integer;

begin

while y<>0 do

begin

t:= x mod y;

x:=y;

y:=t;

end;

ucln:=x;

end;

procedure ip;

begin

assign(f,fi);

reset(f);

read(f,a,b,c);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

for i:=b to c do

begin

if i mod a=0 then write(f,i,' ');

t:=t+i;

end;

writeln(f);

while t<>0 do

begin

t:=t div 10;

inc(d);

end;

writeln(f,d);

if ucln(a,b,c)=1 then write(f,1) else write(f,0);

close(f);

end;

begin

ip;

out;

end.