fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,j,a;
  7. int i,ss=0,c=1,sm,k;
  8. cout<<"Enter Number :\n ";
  9. cin>>n;
  10. if((n%2)!=0)
  11. {
  12. ss=(n/2)+1;
  13. sm=(n*2)-1;
  14. for(a=0;a<=(n+(n/2));a++){
  15. if(a<((n/2)+1)){
  16. for(i=0;i<ss;i++){
  17. cout<<" ";
  18. }
  19. ss--;
  20. for(j=0;j<c;j++){
  21. cout<<"@";
  22. }
  23. }
  24. if(a<(n/2)){
  25. for(k=0;k<sm;k++){
  26. cout<<" ";
  27. }
  28. sm=sm-2;
  29. }else if(a==(n/2)){
  30. for(j=0;j<n;j++){
  31. cout<<"*";
  32. }
  33. }else if(a>((n/2)+1)){
  34. for(k=0;k<=n;k++){
  35. cout<<" ";
  36. }
  37. }
  38. if(a<((n/2)+1)){
  39. for(j=0;j<c;j++){
  40. cout<<"@";
  41. }
  42. c=c+2;
  43. cout<<"\n";
  44. }
  45. if(a>((n/2)+1)){
  46. for(j=0;j<n;j++){
  47. cout<<"*";
  48. }
  49. cout<<"\n";
  50. }
  51. }
  52. }
  53. else
  54. {
  55. cout<<"error";
  56. }
  57. return 0;
  58. }
Success #stdin #stdout 0s 15232KB
stdin
4
stdout
Enter Number :
 error