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 <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 <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;
}
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.
câu 1
Program Nguyen_to;
Var n,i:integer;
Function NT(n:integer):Boolean;
Var ok: Boolean;
i: integer;
Begin ok:=true;
for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;
if n < 2 then NT:=false else NT:=ok;
End;
Begin Write('Nhap n: ');
Readln(n); i:=n;
Repeat i:=i+1;
Until NT(i);
Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);
Readln End.
câu 2
uses crt;
const so: set of char=['0','1','2','3','4','5','6','7','8','9'];
var a:array[1..100] of integer;
st,b:string;
c,l,i,n,j:integer;
s, Max: integer;
begin clrscr;
write('Nhap xau:');
readln(st);
l:=length(st);
i:=1;
n:=0;
repeat if (st[i] in so) then begin b:='';
repeat b:=b+st[i];
inc(i);
until (not(st[i] in so)) or (i>l);
inc(n);
val(b,a[n],c);
end;
inc(i);
until i>l;
Max:=a[1];
for i:=2 to n do If Max<A[i] Then Max:=A[i];
Writeln('Phan tu lon nhat cua mang:', Max);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
long a[105], i,n,max,vt;
cout<<"n="; cin>>n;
for (i=1; i<=n; i++)
{
cout<<"A["<<i<<"]="; cin>>a[i];
}
max=a[1];
for (i=1; i<=n; i++)
if (max<a[i]) max=a[i];
vt=1;
for (i=1; i<=n; i++)
if (max==a[i]) vt=i;
cout<<max<<endl;
cout<<vt;
return 0;
}
#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;
}
#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 <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;
}