how to make triangle with number?

i Write a program to print a triangle, star (*) is change with number from the largest possible number to 01 (reversed) but with my code it's doesnt work this my code:

#include <iostream>
#include <conio.h>
#include<cstdlib>
#include<stdio.h>
using namespace std;

int main()

{

int i,j,max,a=1,b;

system("cls");

cout<<"ENTER THE NO: ";
cin>>max;
for(i=1;i<=max;i++)

{

b=max-1;//untuk spasi

for(j=1;j<=i;j++)

{

for(;b>=i-1;b--)

cout<<" ";

if(a<10)

cout<<" 0"<<a++;

else

cout<<" "<<a++;

}

printf("\n");

}

getch();
Last edited on
Topic archived. No new replies allowed.