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.
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
cin >>x>>y;
cout<<x<<" "<<y;
swap(x,y);
cout<<x<<" "<<y;
return 0;
}
1:
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
t:=t+i*i;
write(t);
readln;
end.
2
program bt2;
var i,n,t:integer;
begin
readln(n);
s:=0;
for i:=1 to n do
if i mod 2 = 1 then s:=s+i;
readln;
end.
program tinh;
uses crt;
var i,n,x:integer;
t:longint;
function luythua(n,x:integer):longint;
var m:integer;
begin
m:=1;
for i:=1 to n do
m:=m*x;
luythua:=m;
end;
function giaithua(n:integer):longint;
begin
if n=0 then giaithua:=1
else giaithua:=n*giaithua(n-1);
end;
begin
clrscr;
write('nhap n,x:');readln(n,x);
t:=0;
for i:=1 to n do
t:=t+giaithua(luythua(i,x));
writeln(t);
readln;
end.
Câu 1:
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=1;
for i:=1 to n do
s:=s*i;
writeln(s);
readln;
end.
Câu 2:
uses crt;
var t,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
t:=t+i;
writeln(t);
readln;
end.
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n>0 && n%5==0) cout<<"Phai";
else cout<<"Khong phai";
}
program trungbinh;
uses crt;
var n,i: integer;
s:real;
A: array[1..1000] of integer;
begin
clrscr;
write('Nhap do dai day: '); readln(n);
writeln('Nhap gia tri cua day: ');
S:=0;
for i:=1 to n do
begin
write('A[',i,']= ');
readln(A[i]);
S:=S+A[i];
end;
S:=S/n;
write('Trung binh cua cac so cua day do la: ',S);
readln;
end.
program tim_max;
uses crt;
var i,n,max:integer;
x:array[1..100]of byte;
begin
clrscr;
write('nhap so n:');readln(n);
i:=1;
while i<=n do
begin
write('x[',i,']=');readln(x[i]);
i:=i+1;
end;
max:=x[1];i:=1;
while i<=n do
begin
if max<x[i] then max:=x[i];
i:=i+1;
end;
write('so lon nhat la:',max);
readln;
end.
program xmun;
uses crt;
var i,x,n,kq:longint;
Begin
clrscr;
writeln('Chuong trinh tinh X^n');
write('X=');readln(x);
write('n=');readln(n);
kq:=1;
for i:=1 to n do
kq:=kq*x;
writeln(x,'^',n,'=',kq);
readln;
end.
uses crt;
var n,x,i:integer;
lt:longint;
begin
clrscr;
write('n='); readln(n);
write('x='); readln(x);
lt:=1;
for i:=1 to x do
lt:=lt*n;
writeln(x,'^',n,'=',lt);
readln;
end.