Quote:
|
Originally Posted by nithinks
Okay another challenge ..
Can you write a C program to print the number in the format given below?
and so on
|
Don't think mine's so efficient but it kind of does the job:
Code:
#include<iostream>
using namespace std;
/*
1
323
43234
5432345
*/
int main()
{
int count = 1, temp=1, i, j, k;
for(int times=1;times<5;times++)
{
for(i=5;i>=times;i--)
{
cout<<" ";
if(i==1)
{
cout<<1;
}
}
for(k=temp;k>=2;k--)
{
cout<<k;
}
for(j=3;j<=temp;j++)
{
cout<<j;
}
if(temp==1)
{
temp+=2;
}
else
{
temp++;
}
count+=1;
cout<<endl;
}
}