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.

8 tháng 9 2021

#include <iostream>
using namespace std;
int main()
{
    int n,i,j;
    cout<<"Nhap n="; cin>>n;
    for (i=1; i<=n; i++)
    {
        for (j=i; j<=i+n-1; j++)
            cout<<j<<" ";
        cout<<endl;
    }
    return 0;
}

8 tháng 9 2021

#include <iostream>
using namespace std;
int main()
{
    int t,m,n,ucln;
    cout<<"Nhap n="; cin>>n;
    cout<<"Nhap m="; cin>>m;
    t=m%n;
    while (t!=0)
    {
        t=n%m;
        n=m;
        m=t;
    }
    ucln=n;
    cout<<ucln;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int n,i,j;
    cout<<"Nhap n="; cin>>n;
    for (i=1; i<=n; i++)
    {
        for (j=i; j<=i+n-1; j++)
            cout<<j<<" ";
        cout<<endl;
    }
    return 0;
}

 

#include <bits/stdc++.h>

using namespace std;

long long a,b;

char st;

int main()

{

cin>>a>>b;

cout<<"Nhap phep tinh:"; cin>>st;

if (st=='+') cout<<a+b;

if (st=='-') cout<<a-b;

if (st=='*') cout<<a*b;

if (st=='/') cout<<a/b;

return 0;

}

23 tháng 1 2022

minh tap lap trinh pascal ma du sao cung cam mon ban da co long tot

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.

19 tháng 10 2021

#include <bits/stdc++.h>

using namespace std;

long n,i,dem,t;

int main()

{

cin>>n;

dem=0;

t=0;

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

if (n%i==0) 

{

dem++;

t=t+i;

}

cout<<dem<<" "<<t;

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)

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

}

D
datcoder
CTVVIP
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;

}

#include <bits/stdc++.h>

using namespace std;

long long a[100],n,i,ln,nn,vt1,vt2;

int main()

{

cin>>n;

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

ln=a[1];

nn=a[1];

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

{

ln=max(ln,a[i]);

nn=min(nn,a[i]);

}

cout<<ln<<" "<<nn;

return 0;

}

19 tháng 1 2022

Var n,i,vtl,vtn,so max,min:integer;

Begin

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

vtl:=0;

vtn:=0;

max:=-32768;

min:=32767;

For i:=1 to n do

Begin

Write('Nhap vao so thu ',i);readln(so);

If so > max then

Begin

Max:=so;

vtl:=i;

End;

If so < min then

Begin

Min:=so;

vtn:=i;

End;

Writeln('So lon nhat la ',max,' tai vi tri thu ',i);

Write('So nho nhat la ',min,' tai vi tri thu ',i);

Readln;

End.