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