Any language will do yaar, I just want the logic. U may give it to me in C/C++/Java...This pyramid structure we created in C & C++
Do u want the same in those languages?
A
ABA
ABCBA
ABCDCBA
^^ that won't do if the query is right. See there's 1 in the first line, then 3, 4, 5 and 6. Looks really odd to me.
1,3,5,7 could still have been understood but 1,3,4,5,6 doesn't make any sequence to me
Yup. That's what I said na!Yeah what mehulved said.
********** A
*********A B A
********A B B A
*******A B C B A
*******A B C C B A
Your pyramid is either wrong or doesnt follow a predetermined sequence.
Should it be ?
Code:A ABA ABCBA ABCDCBA
Should it be ?
Code:A ABA ABCBA ABCDCBA
for (i=1,s=n-1; i<n,s>=0;s--,i++)
{
for(j=1;j<=s;j++)
{cout<<" ";}
for(j=0;j<i;j++)
{cout<<a[j];}
for(j=j;//not sure about this part, try it j>=0;j++)
{cout<<a[j];}
cout<<endl;
}
#include<stdio.h>
#include<conio.h>
int main()
{
int SIZE,i,j,k,l;
char X='A';
printf("Enter the number of rows\n");
scanf("%d",&SIZE);
//a=5;
for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE-i-1;j++)
{
printf(" ");
}
for(k=0;k<i+1;k++)
{
printf("%c",X);
X++;
}
X--;
for(l=0;l<i;l++)
{
X--;
printf("%c",X);
}
X='A';
printf("\n");
}
getch();
return 0;
}
//****A
//***ABA
//**ABCBA
//*ABCDCBA
//ABCDEDCBA
public void pascal_char(char a)
{
int sp=((int)a-1)-96; //ASCII for character a is 96
//I Loop conrols the vertical movement
for(char i='a'; i<=a; i++)
{
//K loop prints the spaces
for(int k=0; k<sp; k++)
{
System.out.print(" ");
}
sp--; //Decrease spaces by one in each line
//J Loop prints the characters, Forwards in each line
for(char j='a'; j<=i; j++)
{
System.out.print(j);
}
//L Loop prints the chars, Backwards in each line
for(char l= (char)(i-1); l>='a'; l--)
{
System.out.print(l);
}
System.out.println();
}
}