Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // For Jake @ signals music
- #include <iostream>
- #include <iomanip>
- using namespace std;
- typedef unsigned long long number;
- char rootNote = 'F';
- static unsigned fixedWidth = 1;
- void out(number n)
- {
- //cout << setw(fixedWidth * 2) << fixed << std::setprecision(0) << n; // for floating point
- //cout << setw(fixedWidth * 2) << n; // for integers
- cout << " " << (char)('A' + (((n - 1) + (rootNote - 'A')) % 7)); // for note names
- }
- int main(int argc, const char * argv[])
- {
- number rows = 8;
- for (number row = 0; row < rows; ++row)
- {
- cout << string((rows - 1 - row) * fixedWidth, ' ');
- number last = 1;
- out(last);
- for (int column = 1; column <= row; ++column)
- {
- number next = (last * (row + 1 - column)) / column;
- out(next);
- last = next;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment