Advertisement
Johnqc

semana9 problema3

May 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <locale.h>
  5. using namespace std;
  6.  
  7. /*
  8. using namespace std;
  9. void DibujaCuadrado(string *cuadro, int n) {
  10. for (int i = 0; i < n; i++) {
  11. for (int j = 0; j < n; j++) {
  12. cout << " " << *cuadro << " ";
  13. }
  14. cout << endl;
  15. }
  16.  
  17.  
  18. }
  19. int main() {
  20. int n;
  21. cout << "Ingrese un numero para calcular la dimencíón del cuadro: "; cin >> n;
  22. string* cuadro = new string;
  23. cout << "Ingrese la palabra: "; cin >> *cuadro;
  24.  
  25. DibujaCuadrado(cuadro, n);
  26.  
  27.  
  28.  
  29.  
  30.  
  31. _getch();
  32. return 0;
  33. }*/ // Problema 1 y 2
  34.  
  35. void PosicionX(int x) {
  36. for (int i = 0; i < x; i++) {
  37. cout << " ";
  38. }
  39. }
  40.  
  41.  
  42. void PosicionY(int y) {
  43. for (int i = 0; i < y; i++) {
  44. cout << endl;
  45. }
  46.  
  47. }
  48.  
  49. void DibujarCuadro(int n, char *caracter) {
  50. for (int i = 0; i < n; i++) {
  51. for (int j = 0; j < n; j++) {
  52. PosicionX;
  53. cout << *caracter;
  54. } PosicionY;
  55. }
  56. }
  57.  
  58.  
  59. int main() {
  60. setlocale(LC_CTYPE, "Spanish");
  61. int n, x, y;
  62. char *caracter = new char;
  63. cout << "Ingresla la dimesión del cuadrado: "; cin >> n;
  64. cout << "Ingresa la posición Y: "; cin >> y;
  65. cout << "Ingresa la posición X: "; cin >> x;
  66. cout << "Ingrese el carácter: "; cin >> *caracter;
  67. PosicionX(x);
  68. PosicionY(y);
  69. DibujarCuadro(n, caracter);
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. _getch();
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement