fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a,b,c,d,e,f,g;
  6. cin>>a;
  7. for(b=0; b<a-1; b++)
  8. {
  9. if(b==0)
  10. {
  11. for(c=0; c<a-1; c++)
  12. {
  13. cout<<" ";
  14. }
  15. cout<<"*";
  16. for(c=0; c<a-1; c++)
  17. {
  18. cout<<" ";
  19. }
  20. cout<<endl;
  21. continue;
  22. }
  23. for(c=b; c<a-1; c++)
  24. {
  25. cout<<" ";
  26. }
  27. cout<<"*";
  28. for(c=0; c<b; c++)
  29. {
  30. cout<<" ";
  31. }
  32. for(c=0; c<b-1; c++)
  33. {
  34. cout<<" ";
  35. }
  36. cout<<"*"<<endl;
  37. }
  38. for(b=1; b<=a; b++)
  39. {
  40. if(b==a)
  41. {
  42. for(c=0; c<a-1; c++)
  43. {
  44. cout<<" ";
  45. }
  46. cout<<"*";
  47. continue;
  48. }
  49. for(c=0; c<b-1; c++)
  50. {
  51. cout<<" ";
  52. }
  53. cout<<"*";
  54. for(c=0; c<a-b; c++)
  55. {
  56. cout<<" ";
  57. }
  58. for(c=0; c<a-b-1; c++)
  59. {
  60. cout<<" ";
  61. }
  62. cout<<"*"<<endl;
  63. }
  64. return 0;
  65. }
Success #stdin #stdout 0.01s 5416KB
stdin
2
stdout
 * 
* *
 *