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.
uses crt;
var n,i:integer;
s:real;
//chuongtrinhcon
function gthua(n:integer):real;
var gt:real;
i:integer;
begin
gt:=1;
for i:=1 to n do
gt:=gt*i;
gthua:=gt;
end;
//chuongtrinhcon
function lthua(n,x:integer):real;
var lt:real;
i:integer;
begin
lt:=1;
for i:=1 to x do lt:=lt*x;
lthua:=lt;
end;
//chuongtrinhchinh
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+(lthua(i,i)/gthua(i));
writeln(s:4:2);
readln;
end.
uses crt;
var a,n,i:integer;
s:real;
begin
clrscr;
write('a='); readln(a);
write('n='); readln(n);
s:=0;
for i:=0 to n do
s:=s+1/(a+i);
writeln('tong la: ',s:4:2);
readln;
end.
Câu 4:
a)
uses crt;
var n:integer;
{---------------------ham-tinh-giai-thua-----------------------}
fucntion gt(x:integer):real;
var i:integer;
begin
gt:=1;
for i:=1 to x do
gt:=gt*i;
end;
{--------------------chuong-trinh-chinh---------------------}
begin
clrscr;
write('Nhap n='); readln(n);
writeln(gt(n):0:0);
readln;
end.
b)
uses crt;
var n:integer;
{-------------------thu-tuc-tinh-giai-thua------------------------}
procedure gt(x:integer);
var i:integer;
begin
gt:=1;
for i:=1 to x do
gt:=gt*i;
writeln(gt);
end;
{-----------------chuong-trinh-chinh--------------------------}
begin
clrscr;
write('Nhap n='); readln(n);
gt(n);
readln;
end.
uses crt;
var i,n:integer;
s,t:real;
begin
clrscr;
readln(n);
s:=0.5;
for i:=2 to n do
s:=s+1/(i+1);
writeln('tong la: ',s:5:2);
readln;
end.
Câu 3:
#include <bits/stdc++.h>
using namespace std;
string a[1000];
int n,i,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>a[i];
if (a[i]=='a') dem++;
}
cout<<dem;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,k,x,tam,vt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n-1 do
for k:=i+1 to n do
if a[i]<a[k] then
begin
tam:=a[i];
a[i]:=a[k];
a[k]:=tam;
end;
write('Nhap gia tri x:'); readln(x);
i:=1;
while (x<a[i]) and (i<=n) do
inc(i);
for k:=n+1 downto i do
a[k]:=a[k-1];
a[i]:=x;
writeln('Mang da chen x la: ');
for i:=1 to n+1 do
write(a[i]:4);
writeln;
for i:=1 to n+1 do
if a[i]=x then vt:=i;
writeln('Vi tri da chen la: ',vt);
readln;
end.
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
n:=1;
s:=1;
while 1/n>1/100 do
begin
n:=n+1;
s:=s+1/n;
end;
writeln(s:4:2);
readln;
end.