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.
uses crt;
var n,i:longint;
kt:boolean;
begin
clrscr;
readln(n);
if (n<2) then writeln('Nhap lai')
else
begin
kt:=true;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then
begin
kt:=false;
break;
end;
if kt=true then writeln('la so nguyen to')
else writeln('khong la so nguyen to');
end;
readln;
end.
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.
uses crt;
var a,b:longint;
Begin
clrscr;
Writeln('Nhap a,b=');
Readln(a,b);
writeln('tich hai so la : a*b=',a*b);
writeln('thuong hai so la :a/b=',a/b);
Readln;
End.
program ho_tro;
uses crt;
var n,i: integer;
s: longint;
begin
clrscr;
writeln(' nhap so n'); readln(n);
s:=0;
for i:=1 to n do
s:=s+i;
writeln(' tong cua' , n, ' so tu nhien dau tien =' , s);
readln
end.
uses crt;
var n,i,t:int64;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<1000000000);
t:=0;
for i:=1 to n-1 do
if n mod i=0 then t:=t+i;
if t=n then writeln(n,' la so hoan hao')
else writeln(n,' khong la so hoan hao');
readln;
end.
Program hotrotinhoc;
var s: longint;
i,n: integer;
function lt(x,y: integer): longint;
var l,t: longint;
begin
t:=1;
for l:=1 to y do t:=t*x;
lt:=t;
end;
begin
write('N='); readln(n);
for i:=2 to n do
if (i-1) mod 2<>0 then s:=s+lt((i-1),i)
else
if (i-1) mod 2=0 then s:=s-lt((i-1),i);
write(s);
readln
end.
Mik học tin cx đc nhưng lâu quá rùi nên cx quên rùi
Hic!