fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int A , B;
  8. cin >> A >> B;
  9. float div1=A/B;
  10. int div2 =A/B;
  11. double sub = div1-div2;
  12. int Floor=div2;
  13. int Ceil = div2+1;
  14. int round ;
  15. if (sub>=0.5){
  16. round = div2+1;
  17. }
  18. else if(sub<0.5){
  19. round=div2;
  20. }
  21. cout <<sub<<endl;
  22. cout << "floor"<< A<< "/"<< B << " = " << Floor << "\n";
  23. cout << "ceil"<< A << "/" <<B << " = " << Ceil<< "\n";
  24. cout << "round"<< A <<"/" <<B << " = " << round << "\n";
  25.  
  26.  
  27. return 0;
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
0
floor-146314464/5355 = -27322
ceil-146314464/5355 = -27321
round-146314464/5355 = -27322