WeltEnSTurm

Untitled

Sep 30th, 2010
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. double t[10000]={};
  8. int idx=0;
  9.  
  10. double step(double x, double y){
  11.     if(floor(x/2)!=x/2){
  12.         t[idx]=y;
  13.         idx++;
  14.         cout<<idx<<endl;
  15.     }
  16.     if(x==1){
  17.         double temp=0;
  18.         for(int i=0;i<=idx;i++)
  19.             temp=temp+t[i];
  20.         return temp;
  21.     }else{
  22.         x=floor(x/2);
  23.         y=y*2;
  24.         return(step(x,y));
  25.     }
  26.     return 0;
  27. }
  28.  
  29. int main(){
  30.     while(true){
  31.         cout<<"enter 2 numbers separated with space"<<endl;
  32.         double in1=0;
  33.         double in2=0;
  34.         cin>>in1>>in2;
  35.         cout<<step(in1,in2)<<endl;
  36.     }
  37.     return 0;
  38. }
Add Comment
Please, Sign In to add comment