Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. include<iostream>
  2. using namespace std;
  3. int k, n, penultimul, ultimul;
  4. double ratie, ratie_2;
  5. int main(){
  6. cin>>k>>n;
  7. penultimul=1;
  8. ultimul=1;
  9. int i=0;
  10. int p=1;
  11. for(int j=1; j<k; j++) p=p*10;
  12. while(i<=n){
  13. ratie=(double)ultimul/(double)penultimul;
  14. int aux=penultimul;
  15. penultimul=ultimul;
  16. ultimul=aux+penultimul;
  17. ratie_2=(double)ultimul/(double)penultimul;
  18. if( (int) (ratie*p)==(int)(ratie_2*p)){
  19. cout<<penultimul<<"/"<<aux<<";"<<ultimul<<"/"<<penultimul<<"="<<ratie_2<<endl;
  20. i++;
  21.  
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement