Advertisement
Guest User

Problem P87198_ca: Octàgons facilets

a guest
Mar 6th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n;
  6.  
  7. while (cin >> n){
  8. int contador_x = n;
  9. int contador_espacios = n - 1;
  10. for (int i = 0; i < n - 1; ++i){//Esta es la primera parte del octagono, con n-1 filas
  11. for (int j = 0; j < 3*n - 2; ++j){
  12. if (j < contador_espacios) cout << " ";
  13. if (j >= contador_espacios and j < (contador_espacios+contador_x)) cout << "X";
  14. }
  15. --contador_espacios;
  16. contador_x += 2;
  17. cout << endl;
  18. }
  19. for (int i = 0; i < n;++i){ //Esta es la parte del medio del octagono
  20. for (int j = 0; j < 3*n-2; ++j) cout << "X";
  21. cout << endl;
  22. }
  23. contador_espacios = 1;
  24. contador_x = 3*n - 4;
  25. for (int i = 0; i < n - 1; ++i){//Esta es la tecera parte del octagono, con n-1 filas
  26. for (int j = 0; j < 3*n - 2; ++j){
  27. if (j < contador_espacios) cout << " ";
  28. if (j >= contador_espacios and j < (contador_espacios+contador_x)) cout << "X";
  29. }
  30. ++contador_espacios;
  31. contador_x -= 2;
  32. cout << endl;
  33. }
  34. cout << endl;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement