fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. void printNumber(int x) {
  5. std::cout << "X:" << std::setw(6) << x << ":X\n";
  6. }
  7.  
  8. void printStuff() {
  9. printNumber(528);
  10. printNumber(3);
  11. printNumber(73826);
  12. printNumber(37);
  13. }
  14.  
  15. int main() {
  16. std::cout << "Left-aligned\n";
  17. std::cout << std::left;
  18. printStuff();
  19. std::cout << "Right-aligned\n";
  20. std::cout << std::right;
  21. printStuff();
  22.  
  23. }
Success #stdin #stdout 0.02s 2680KB
stdin
Standard input is empty
stdout
Left-aligned
X:528   :X
X:3     :X
X:73826 :X
X:37    :X
Right-aligned
X:   528:X
X:     3:X
X: 73826:X
X:    37:X