fork download
  1.  
  2.  
  3. #include <iostream>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int a = 45;
  11. float b = 45.323;
  12. double c = 45.5468;
  13. int aa = a + 9;
  14. float bb = b + 9;
  15. double cc = c + 9;
  16. int aaa = aa + 9;
  17. float bbb = bb + 9;
  18. double ccc = cc + 9;
  19.  
  20. // 1st attempt :>
  21.  
  22. cout << "\n\n\n" << "// 1st attempt :>" << "\n";
  23. cout << "12345678901234567890123456789012345678901234567890" << "\n";
  24. cout << "Ints" << setw(15) << "Floats" << setw(15) << "Doubles" << "\n";
  25. cout << a << setw(15) << b << setw(15) << c << "\n";
  26. cout << aa << setw(15) << bb << setw(15) << cc << "\n";
  27. cout << aaa << setw(15) << bbb << setw(15) << ccc << "\n";
  28.  
  29. // 2nd attempt :>
  30.  
  31. cout << "\n\n\n" << "// 2nd attempt :>" << "\n";
  32. cout << "12345678901234567890123456789012345678901234567890" << "\n";
  33. cout << setw(15) << std::left << std::setfill(' ') << std::setw(15) << "Ints" << setw(15) << "Floats" << setw(15) << "Doubles" << "\n";
  34. cout << a << setw(15) << b << setw(15) << c << "\n";
  35. cout << setw(15) << std::left << std::setfill(' ') << setw(15) << aa << setw(15) << bb << setw(15) << cc << "\n";
  36. cout << aaa << setw(15) << bbb << setw(15) << ccc << "\n";
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 4164KB
stdin
Standard input is empty
stdout


// 1st attempt :>
12345678901234567890123456789012345678901234567890
Ints         Floats        Doubles
45         45.323        45.5468
54         54.323        54.5468
63         63.323        63.5468



// 2nd attempt :>
12345678901234567890123456789012345678901234567890
Ints           Floats         Doubles        
4545.323         45.5468        
54             54.323         54.5468        
6363.323         63.5468