Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double input(void);
- int main(){
- double pgrnst=input(), zs1, zs2=1, rznst;
- int fib1=1, fib2=1, buf;
- int i=1;
- do{
- zs1 = zs2;
- buf = fib2;
- fib2 += fib1;
- fib1 = buf;
- zs2 = (double)fib2/fib1;
- rznst = (zs2-zs1)<0 ? zs1-zs2: zs2-zs1;
- i++;
- }
- while(rznst>pgrnst);
- printf("%.10lf\n", zs2);
- printf("Nomer shaga: %d\n", i);
- }
- double input(){
- double a;
- while(scanf("%lf", &a)!=1 && a>0){
- while(getchar()!='\n');
- printf("Enter correct value: ");
- }
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement