beep, boop
This commit is contained in:
parent
f79359da32
commit
f83237f21b
|
@ -0,0 +1,13 @@
|
|||
* Lecture 3 agenda (January 22nd 2024)
|
||||
+ Venting about being iced in!
|
||||
+ Formatting (a.k.a let's make a table!!!)
|
||||
+ setw
|
||||
+ left
|
||||
+ right
|
||||
+ setfill
|
||||
+ setprecision
|
||||
+ fixed
|
||||
+ Review of while-loops
|
||||
+ Review of if-statements
|
||||
+ A taste of for-loops (and what they're good for)
|
||||
+ Time to work
|
|
@ -0,0 +1,39 @@
|
|||
#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;
|
||||
}
|
Loading…
Reference in New Issue