HackerRank C++ Print Pretty




Your manager gave you a text file with many lines of numbers to format and print. For each row of 3 space-separated doubles, format and print the numbers using the specifications in the Output Format section below.



  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main()
  5. {
  6. int T; cin >> T;
  7. cout << setiosflags(ios::uppercase);
  8. cout << setw(0xf) << internal;
  9. while(T--)
  10. {
  11. double A; cin >> A;
  12. double B; cin >> B;
  13. double C; cin >> C;
  14. cout << resetiosflags(ios::uppercase|ios::scientific);
  15. cout << std::setiosflags (ios::left|ios::fixed);
  16. cout << setw(0) << std::hex;
  17. cout << std::setiosflags (ios::showbase);
  18. cout << (unsigned long)A << std::endl;
  19. cout << resetiosflags(ios::showbase);
  20. cout << setw(0xf) << setfill('_')<< std::dec ;
  21. cout << setiosflags (ios::showpos) << setprecision(2);
  22. cout << B << endl;
  23. cout << resetiosflags(ios::fixed|ios::showpos);
  24. cout << setiosflags (ios::scientific | ios::uppercase) << setprecision(9);
  25. cout << C << std::endl;
  26. }
  27. return 0;
  28. }
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube