my code has become somewhat of a mess from trying to move things around and figure out what isn't working.
Basically, what i want it to do is, say the user enters 3, i want it to print out:


Could you guys give me some help? i feel like I'm close but I'm just missing one small but important step

edit: I'm not sure how formatting works on here but that should be 2 spaces on the first line, then the 1, 1 space on 2nd line, then the 2, and no spaces on the 3rd line

You can do it by using a recursive procedure with two for loops, first one will be in reverse order and concatinate the decremented/incremented value to a string variable.

#include <iostream>
#include <iomanip>

using namespace std;

void piramid(int count){
    setfill(" ");
    for(int i=0; i<count; i++){
        cout << setw(count-i) << (i+1);
        for(int j=i; j>0; j--){ cout << j; }
        for(int j=1; j<=i; j++){ cout << (j+1); }
        cout << "\n";
    cout << "\n";

int main(){
    return 0;

Thanks for the help, I think ive got it now.

void pyramid(int count){
    cin >> lineTotal;
    count = lineTotal;
    for(int line=0; line < count; line++){
        if (count >= 10){
            int width=(count-line)*2;
            if (line<9) width--;
            cout << setw( width ) << line+1;
        else {
            cout << setw(count-line) << (line+1);

        for(int leftside = line; leftside > 0; leftside--){
            cout << setw(count>9&&leftside!=9?2:1) << leftside;
        for(int rightside = 1; rightside <= line; rightside++){
            cout << setw(count>9?2:1) << (rightside + 1);
        cout << endl;
    cout << endl;