C,
pasted
on Aug 21:
|
#include<stdio.h>
#include<conio.h>
int main()
{
int i, n;
float S;
i = 0;
S = 1;
printf("\nNhap n: ");
scanf("%d", &n);
while(i <= n)
{
S = 1 + 1.0/S;
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
kendypham
on Nov 15
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
int n,i;
float s = 0;
printf("Nhap vao n : ");
scanf("%d", &n);
for ( i = 1; i <= n; i++)
s = 1 / (1 + s);
printf("S(n) = %f", s);
getch();
}
reply
posted by
dangtiendat86@gmail.com
on Feb 5
#include<iostream>
using namespace std;
main(){
int n;
cout<<"n=";
cin>>n;
float s=1;
for (int i=1; i<=n; i++){
s=1.0/(s+1);
}
cout<<"kq="<<s<<endl;
}
reply
posted by
thang699
on Aug 12
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
int n;
cout<<"nhap gia tri cua n: ";
cin>>n;
if(n<1)
{
cout<<"nhap lai gia tri cua n: "<<endl;
main ();
}
float sum = 1;
for(int i=1;i<=n;i++)
{
sum = 1.0/( 1 + sum );
}
cout<<"gia tri can tim la: "<<sum<<endl;
}
reply
posted by
tridv
on Feb 13
bài này code mẫu sai đúng không mọi người, vốn dĩ
S = 1/(1 + x) với x > 0 thì S luôn luôn < 1 rồi mà mình thử code mẫu kết quả ra > 1
reply