Guest User

Pascal's prison

a guest
Feb 1st, 2021
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. // For Jake @ signals music
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. typedef unsigned long long number;
  8.  
  9. char rootNote = 'F';
  10. static unsigned fixedWidth = 1;
  11.  
  12. void out(number n)
  13. {
  14.     //cout << setw(fixedWidth * 2) << fixed << std::setprecision(0) << n;   // for floating point
  15.     //cout << setw(fixedWidth * 2) << n;                                      // for integers
  16.     cout << " " << (char)('A' + (((n - 1) + (rootNote - 'A')) % 7));        // for note names
  17. }
  18.  
  19. int main(int argc, const char * argv[])
  20. {
  21.     number rows = 8;
  22.     for (number row = 0; row < rows; ++row)
  23.     {
  24.         cout << string((rows - 1 - row) * fixedWidth, ' ');
  25.         number last = 1;
  26.         out(last);
  27.         for (int column = 1; column <= row; ++column)
  28.         {
  29.             number next = (last * (row + 1 - column)) / column;
  30.             out(next);
  31.             last = next;
  32.         }
  33.         cout << endl;
  34.     }
  35.    
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment