fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5.  
  6. string dots(int times, string sym = "."){
  7. string result = "";
  8. for (int i = 0; i < times; ++i){
  9. result += sym;
  10. }
  11. return result;
  12. }
  13.  
  14. string space( int times, string sym = " "){
  15. string result = "";
  16. for (int i = 0; i < times; ++i){
  17. result += sym;
  18. }
  19.  
  20. return result;
  21. }
  22. int main() {
  23. double n;
  24. cin>> n;
  25. int a = (n - 0.5) * 2;
  26. for (int i = 0; i < n; ++i){
  27. cout<< space(i);
  28. cout<< "\\";
  29. cout<< dots(a);
  30. cout<< "/" << endl;
  31. a -= 2;
  32. }
  33. cout<< space(n);
  34. cout<< "X" << endl;
  35. int m = 1;
  36. for (int i = n; i > 0; --i){
  37.  
  38. cout<< space(i - 1);
  39. cout<< "/";
  40. cout<< dots(m);
  41. cout<< "\\" << endl;
  42. m += 2;
  43. }
  44.  
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0.01s 5316KB
stdin
4
stdout
\......./
 \...../
  \.../
   \./
    x
   /.\
  /...\
 /.....\
/.......\