C,
pasted
on Aug 17:
|
#include<stdio.h>
#include<conio.h>
int main()
{
int i, n;
float x, S, T;
long M;
printf("\nNhap x: ");
scanf("%f", &x);
do
{
printf("\nNhap n: ");
scanf("%d", &n);
if(n < 1)
{
printf("\n N phai >= 1. Xin nhap lai !");
}
}while(n < 1);
S = 0;
T = 1;
M = 0;
i = 1;
while(i <= n)
{
T = T * x;
M = M + i;
S = S + T/M;
i++;
}
printf("\nTong la %f", S);
getch();
return 0;
}
|
Output:
|
Line 17: error: conio.h: No such file or directory
|
|
Create a new paste based on this one
Comments:
posted by
Vodong
on Sep 1
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
for(float S=0,y=1,k=0,x,N,a=1;S==0;S=0,y=1,k=0,a=1)
{
cout<<"Nhap x,N: ";
cin>>x>>N;
for(;y<=N;++y)
{
for(;a<=y;++a)
{
k=k+a;
}
S=S+pow(x,y)/k;
}
cout<<"S="<<S;
cout<<endl;
}
return 0;
}
reply
posted by
lethi200397
on Oct 10
#include<stdio.h>
#include<conio.h>
int main()
{
int i=1, n, x;
float T= 0, t = 0 ;
printf(" nhap vao x va n \n ");
scanf("%d%d", &x, &n);
while(i<=n)
{
t = t + i;
T = T + pow(x,(i/t));
i++;
}
printf("t = %f", t);
printf("T = %f", T);
getch();
return 0;
}
reply
posted by
dangtiendat86@gmail.com
on Feb 4
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int x,n;
cout<<"x="; cin>>x;
cout<<"n="; cin>>n;
float s=0, t=0;
for (int i=1; i<=n; i++){
t+=i;
s+=(float)(pow(x,i)/t);
}
cout<<"kq="<<s<<endl;
}
reply
posted by
dangtiendat86@gmail.com
on Feb 4
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int x,n;
cout<<"x="; cin>>x;
cout<<"n="; cin>>n;
float s=0, t=0;
for (int i=1; i<=n; i++){
t+=i;
s+=(float)(pow(x,i)/t);
}
cout<<"kq="<<s<<endl;
}
reply
posted by
Ryan_Dang
on Jul 23
#include <stdio.h>
#include <conio.h>
/*Bài 16: Tính S(n) = x + x^2/1 + 2 + x^3/1 + 2 + 3 + … + x^n/1 + 2 + 3 + …. + N*/
int LuyThua(int x,int n)
{
int i=1,s=1;
while(i<=n)
{
s*=x;
i++;
}
return s;
}
float TinhTong(int x,int n)
{
int i=0,temp=0;
float s=0;
while(++i<=n)
{
temp+= i;
s+=(float)LuyThua(x,i)/temp;
}
return s;
}
void main()
{
int x,n;
do
{
printf("\nNhap Co So:");
scanf("%d",&x);
printf("\nNhap So Mu:");
scanf("%d",&n);
if(x<1) puts("\nSo Nhap Khong Hop Le !!!");
}
while(x<1);
printf("\nTong S=%.4f",TinhTong(x,n));
getch();
}
reply
posted by
Ryan_Dang
on Jul 23
#include <stdio.h>
#include <conio.h>
/*Bài 16: Tính S(n) = x + x^2/1 + 2 + x^3/1 + 2 + 3 + … + x^n/1 + 2 + 3 + …. + N*/
int LuyThua(int x,int n)
{
int i=1,s=1;
while(i<=n)
{
s*=x;
i++;
}
return s;
}
float TinhTong(int x,int n)
{
int i=0,temp=0;
float s=0;
while(++i<=n)
{
temp+= i;
s+=(float)LuyThua(x,i)/temp;
}
return s;
}
void main()
{
int x,n;
do
{
printf("\nNhap Co So:");
scanf("%d",&x);
printf("\nNhap So Mu:");
scanf("%d",&n);
if(x<1) puts("\nSo Nhap Khong Hop Le !!!");
}
while(x<1);
printf("\nTong S=%.4f",TinhTong(x,n));
getch();
}
reply
posted by
minhtampro195@gmail.com
on Feb 3
int cong1(int n)
{
int bt = 0;
for(int i = 2; i <= n; i++)
{
bt = bt + i;
}
return bt;
}
float BAI_16(int n, int x)
{
int bt = x;
for(int i = 2; i <= n; i++)
{
bt = bt + pow(x,i) + cong1(i);
}
return bt;
}
reply
posted by
minhtampro195@gmail.com
on Feb 3
đề mình có phần chưa hiều lắm đề là
Tính S(n) = x + x^2/1 + 2 + x^3/1 + 2 + 3 + … + x^n/1 + 2 + 3 + …. + N
hay Tính S(n) = x + x^2/(1 + 2) + x^3/(1 + 2 + 3 + …)+ x^n/(1 + 2 + 3 + …. + N)
reply