viết chương trình tính biểu thức s=1-x+x^2/2!-x^3/3!+.....+(-1)^n*x^n/n!
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.
2:
#include <bits/stdc++.h>
using namespace std;
double s;
int n,i;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
s=s+(i*1.0)/((i+1)*1.0);
cout<<fixed<<setprecision(2)<<s;
return 0;
}
a)
program Tinh_S;
var
n, S: integer;
i: integer;
begin
write('Nhap gia tri cua n (30 <= n <= 90): ');
readln(n);
S := 0;
if (n >= 30) and (n <= 90) then
begin
for i := 1 to n do
S := S + i;
writeln('Gia tri cua bieu thuc S la: ', S);
end
else
writeln('Gia tri cua n khong hop le!');
readln;
end.
b)
program Tim_n;
var
n, S: integer;
begin
for n := 30 to 90 do
begin
S := 0;
for i := 1 to n do
S := S + i;
if S > 1000 then
begin
writeln('Gia tri cua n la: ', n);
break;
end;
end;
readln;
end.
a)program Tinh_S;
var n,s,i:longint;
begin
s := 0;
write('Nhap n (30 <= n <= 90): ');
readln(n);
for i := 1 to n do
begin
s := s + i;
end;
writeln('Tong S la: ', s);
end.
b) program Tim_N;
var n,s,i: longint;
begin
s := 0;
n := 1;
while s <= 1000 do
begin
s := s + n;
n := n + 1;
end;
writeln('Gia tri n can tim la: ', n-1);
end.
uses crt;
var i,n,s:integer;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+i*i;
writeln(s);
readln;
end.
Bài 1:
function canbac2(x:longint):real;
begin
canbac2:=sqrt(x);
end;
Bài 2:
function tong(n:longint):longint;
var s,i:longint;
begin
s:=0;
for i:=1 to n do
s:=s+i;
tong:=s;
end;
program ho_tro;
uses crt;
var s,n,i: integer;
begin
clrscr;
writeln(' nhap so n:'); readln(n);
s:=1;
for i:=1 to n do
s:=s*i;
writeln(' tich cua day tren la:',s);
readln;
end.
program ho_tro;
uses crt;
var s,n,i: integer;
begin
clrscr;
writeln(' nhap so n:'); readln(n);
s:=1;
for i:=1 to n do
s:=s*i*i;
writeln(' tich cua day tren la:',s);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long i,n;
double p;
int main()
{
cin>>n;
p=0;
for (i=1; i<=n; i++)
p=p+1/(i*1.0);
cout<<p+3*n;
return 0;
}
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 hotrotinhoc;
var n,x,i: integer;
s: real;
function t1(d: integer): longint;
var i,t: longint;
begin
t:=1;
for i:=1 to d do t:=t*i;
t1:=t;
end;
function t2(a,b: integer): longint;
var i,tg: integer;
begin
tg:=1;
for i:=1 to a do tg:=tg*b;
t2:=tg;
end;
begin
write('n='); readln(n);
write('x='); readln(x);
s:=1;
for i:=1 to n do
if i mod 2=1 then s:=s-((t2(i,x))/(t1(i))) else s:=s+((t2(i,x))/(t1(i)));
write(s:1:2);
readln
end.