fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6.  
  7.  
  8. int n=0;
  9.  
  10. cin>>n;
  11.  
  12. if(n%2==0|| n<=1){
  13. cout<<"Pattern Work Only Odd Numbers"<<endl;
  14. return 0;
  15. }
  16.  
  17.  
  18.  
  19.  
  20. int n2 = ceil(n/2.0);
  21. int k=0;
  22.  
  23. for(int i=1;i<=(n+4+n2);i++){
  24. if(i>(n+4)){
  25. k++;
  26. }
  27.  
  28.  
  29. for(int j=1;j<=n;j++){
  30. if(j==n&&i<=(n+4)){
  31. cout<<"#";
  32. }if(j>=k&&j<=n-(k-1)&&i>(n+4)){
  33. cout<<"@";
  34. }else{
  35. cout<<" ";
  36. }
  37.  
  38.  
  39. }
  40. cout<<endl;
  41.  
  42. }
  43.  
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0s 5316KB
stdin
-1
stdout
Pattern Work Only Odd Numbers