40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
#include <iostream>
|
|
#include <iomanip>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
cout << "This is how " << 10 << " things normally appear" << endl;
|
|
|
|
cout << "(Now with default alignment and a width of 20)" << endl;
|
|
|
|
cout << setw(20) << "This is how " << setw(20) << 10 << setw(20) << " things normally appear" << endl;
|
|
|
|
cout << "Why doesn't the last bit look right aligned?" << endl;
|
|
|
|
cout << "Now for messing with alignment" << endl;
|
|
|
|
cout << left << setw(20) << "This is how " << right << setw(20) << 10 << setfill('*') << left << setw(40) << " things normally appear" << endl;
|
|
|
|
cout << endl << endl;
|
|
|
|
cout << "Now let's build a table" << endl;
|
|
|
|
//we build the top of the table
|
|
cout << setfill('-');
|
|
cout << right;
|
|
cout << "|" << setw(21);
|
|
cout << "|" << setw(21);
|
|
cout << "|" << setw(21) << "|" << endl;
|
|
cout << setfill(' ');
|
|
|
|
cout << left;
|
|
|
|
cout << "|" << setw(20) << "Ink name";
|
|
cout << "|" << setw(20) << "Color";
|
|
cout << "|" << setw(20) << "Brand name" << "|" << endl;
|
|
|
|
// we can build the rest of the table
|
|
|
|
return 0;
|
|
}
|