Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(void)
- {
- // Deklarasi variable
- unsigned int line, n, i, j, totalLine, temp;
- unsigned int pos = 0;
- // Jumlah input
- cin >> n;
- if (n > 26) return 22;
- // Menentukan jumlah baris
- for (totalLine = 1, temp = 1; temp < n; temp += ++totalLine);
- for (line = 1; line <= totalLine; line++) {
- // Tulis spasi
- for (i = 0; i < (totalLine - line); i++)
- cout << " ";
- // Tulis karakter
- for (j = 0; j < line && pos < n; j++)
- cout << static_cast<char>('A' + pos++) << " ";
- // Akhiri baris
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement