Guest User

Untitled

a guest
Nov 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. while(scanf("%d%d",&q,&p)==2){ //
  2.  
  3. int sum=0;
  4. double t;
  5.  
  6. //if ( q == 10&& P==10)
  7. //{break;}
  8.  
  9. t=(double)q/p;
  10. sum+=t;
  11. printf("[%d;",(int)t);
  12. q=q-(int)t*p;
  13. SWAP(q,p);
  14. t=(double)q/p;
  15. sum+=t;
  16. printf("%d",(int)t);
  17. q=q-(int)t*p;
  18. while(q!=0){
  19. SWAP(q,p);
  20. t=(double)q/p;
  21. sum+=t;
  22. printf(",%d",(int)t);
  23. q=q-(int)t*p}
  24. printf("]n");
  25.  
  26. array[count]=sum;
  27.  
  28.  
  29. printf("%dn",sum);
  30. printf("%dn",count);
  31.  
  32. for(j=0;j<=count;j++)
  33. {printf("%dn",array[j]);}
  34.  
  35. count++;
  36.  
  37. if( count == 3) {
  38. // terminate the loop using break statement
  39. break;
  40. }
  41.  
  42. }//end while
Add Comment
Please, Sign In to add comment