Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<sstream>
  4. using namespace std;
  5. string palindrome(int n)
  6. {
  7. string num;
  8. for(int i=0;i<n;i++)
  9. {
  10. std::stringstream ss ;
  11. ss<<num<<i+1;
  12. num=ss.str() ;
  13. }
  14. for(int p=n-1;p>0;p--)
  15. {
  16. std::stringstream ss;
  17. ss<<num<<p;
  18. num=ss.str() ;
  19. }
  20. return num;
  21. }
  22. int main()
  23. {
  24. int input,inputman;
  25. cout << "Enter the number of rows for the pyramid: " ;
  26. cin >> input ;
  27. inputman=input;
  28. for(int l=0;l<input+1;l++)
  29. {
  30. for(int y=0;y<inputman-1;y++)
  31. {
  32. cout<<" ";
  33. }
  34.  
  35. string output ;
  36. output = palindrome(l) ;
  37. cout << output <<endl;
  38. inputman=input-l;
  39. }
  40. return 0 ;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement