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.
1:
#include <bits/stdc++.h>
using namespace std;
long long a[100],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
cout<<"Day ban dau la: "<<endl;
for (i=1;i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
sort(a+1,a+n+1);
cout<<"Day tang dan la: "<<endl;
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
Var n,sc,sl,i:longint;
Begin
Write('N = ');readln(n);
Write('Cac so tu 1 den ',n,' la ');
For i:=1 to n do
Write(i:8);
Writeln;
For i:=1 to n do
Begin
If i mod 2 = 0 then sc:=sc+i
Else sl:=sl+i;
End;
Writeln('Tong cac so chan la ',sc);
Write('Tong cac so le la ',sl);
Readln
End.
#include <bits/stdc++.h>
using namespace std;
long long a,b,bcnn;
int main()
{
cin>>a>>b;
if (a>b) swap(a,b);
bcnn=b;
while (bcnn%a!=0)
bcnn=bcnn+b;
cout<<bcnn;
return 0;
}
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('n='); readln(n);
if (n>=0) and (n<=100) then
begin
s:=0;
for i:=1 to n do
s:=s+(i/(i+1));
writeln('tong la: ',s);
end
else writeln('vui long nhap lai');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long i,a,b;
int main()
{
cin>>a>>b;
for (i=1; i<=min(a,b); i++)
if ((a%i==0) and (b%i==0)) cout<<i<<" ";
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,t1,t2,t3:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t1:=0;
t2:=0;
t3:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then t1:=t1+a[i]
else t2:=t2+a[i];
if (a[i] mod 2=0) and (a[i] mod 3=0) then t3:=t3+a[i];
end;
writeln(t1);
writeln(t2);
writeln(t3);
readln;
end.
1.
var n: integer;
begin
repeat
write('Nhap so n: '); readln(n);
until (n>=10) and (99>=n);
writeln('Chu so hang chuc la: ', n div 10);
writeln('Chu so hang don vi la: ', n mod 10);
end.
2.
var n,i: integer;
s: string;
begin
repeat
write('Nhap so n: '); readln(n);
until (n>=100) and (999>=n);
write('So moi la: ');
str(n,s);
for i:=length(s) downto 1 do write(s[i]);
end.
uses crt;
var n,dem,dem1,i,t:integer;
tbc:real;
begin
clrscr;
write('n='); readln(n);
if (0<n) and (n<1000) then
begin
{----------------------dong-1----------------------}
dem:=0;
for i:=1 to n do
if i mod 2=1 then inc(dem);
writeln('so luong cac so nguyen le tu 1 toi ',n,' la: ',dem);
{---------------------dong-2-----------------------}
dem1:=0;
for i:=1 to n do
if i mod 2=0 then inc(dem1);
writeln('so luong cac so nguyen chan tu 1 toi ',n,' la: ',dem1);
{--------------------dong-3------------------------}
t:=0;
for i:=1 to n do
t:=t+i;
tbc:=t/n;
writeln('trung binh cong cac so nguyen tu 1 toi ',n,' la: ',tbc:4:2);
end
else writeln('vui long nhap lai');
readln;
end.
uses crt;
var n,i:longint;
t:real;
begin
clrscr;
write('n='); readln(n);
if (1<=n) and (n<=10000) then
begin
t:=0;
for i:=1 to n do
t:=t+(1/(sqr(i)));
writeln('T=',t:4:2);
end
else writeln('vui long nhap lai n');
readln;
end.