fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int i , j ,n ;
  7. cin >> n;
  8. for (i=1;i<=n;i++) {
  9. for (j=1;j<=i;j++) {
  10. if(j<i){
  11. cout<<i<<"*";
  12. }else {
  13. cout<<i;
  14. }
  15. }
  16. cout<<" "<< endl;
  17. }
  18. for (i=n;i>=1;i--) {
  19. for (j=1;j<=i;j++) {
  20. if(j<i) {
  21. cout << i << "*";
  22. }else {
  23. cout << i;
  24. }
  25. }
  26. cout << " " << endl;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 4504KB
stdin
5
stdout
1 
2*2 
3*3*3 
4*4*4*4 
5*5*5*5*5 
5*5*5*5*5 
4*4*4*4 
3*3*3 
2*2 
1