Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<sstream>
- using namespace std;
- string palindrome(int n)
- {
- string num;
- for(int i=0;i<n;i++)
- {
- std::stringstream ss ;
- ss<<num<<i+1;
- num=ss.str() ;
- }
- for(int p=n-1;p>0;p--)
- {
- std::stringstream ss;
- ss<<num<<p;
- num=ss.str() ;
- }
- return num;
- }
- int main()
- {
- int input,inputman;
- cout << "Enter the number of rows for the pyramid: " ;
- cin >> input ;
- inputman=input;
- for(int l=0;l<input+1;l++)
- {
- for(int y=0;y<inputman-1;y++)
- {
- cout<<" ";
- }
- string output ;
- output = palindrome(l) ;
- cout << output <<endl;
- inputman=input-l;
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement