rizalwildan
12/6/2017 - 2:05 PM

https://drive.google.com/open?id=1Wj5PBhfb8XIUxMhEhB-fr3VujWsPN2Um

#include <iostream>

using namespace std;

int main() {

    int input;

    cout << "input: ";
    cin >> input;

    for (int i = 0; i < input * 2 - 1; ++i) {
        for (int j = 0; j < input * 2 - 1; ++j) {

            bool atas = (j >= input - i - 1) && (j <= input + i - 1);
            bool bawah = (j >= i - input + 1) && (j <= input * 3 - i - 3);

            bool final = (atas && bawah);

            bool setengah = (i < input);

            int angka = (setengah ? (i + 1) : (input * 2) - i - 1) % 10;

            if (final) {
                cout << angka << ' ';
            } else {
                cout << "  ";
            }
        }
        cout << endl;
    }

}