elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Hacer Figuras Con Ciclos
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] Ir Abajo Respuesta Imprimir
Autor Tema: Hacer Figuras Con Ciclos  (Leído 9,832 veces)
dato000


Desconectado Desconectado

Mensajes: 3.034



Ver Perfil
Re: Hacer Figuras Con Ciclos
« Respuesta #10 en: 22 Octubre 2016, 16:33 pm »

Por fin consegui algo de tiempo libre, no creo que sea necesario el uso de funciones. Bueno aquí voy:
Código
  1. #include <stdio.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char **argv)
  7. {
  8. int dimension = 10;
  9. char letra = 'B';
  10.  
  11. /////////////////////
  12. // Triangulo Lleno //
  13. /////////////////////
  14. for(int i=0; i<dimension; i++)
  15. {
  16. for(int k=0; k<=i; k++)
  17. {
  18. cout << letra;
  19. }
  20.  
  21. cout << endl;
  22. }
  23. cout << endl << endl << endl;
  24.  
  25. /////////////////////
  26. // Triangulo Vacio //
  27. /////////////////////
  28. for(int i=0; i<dimension-1; i++)
  29. {
  30. for(int k=0; k<=i; k++)
  31. {
  32. if(k==0 || k==i)
  33. {
  34. cout << letra;
  35. }
  36. else
  37. {
  38. cout << " ";
  39. }
  40. }
  41. cout << endl;
  42. }
  43. for(int i=0; i<dimension; i++)
  44. {
  45. cout << letra;
  46. }
  47. cout << endl;
  48. cout << endl << endl << endl;
  49.  
  50. ///////////////////
  51. // Circulo Lleno //
  52. ///////////////////
  53. for(int i=0; i<dimension; i++)
  54. {
  55. for(int k=0; k<dimension; k++)
  56. {
  57. if( (k==0 && i==0) || (k==0 && i==dimension-1) )
  58. {
  59. cout << " ";
  60. }
  61. else if( (k==dimension-1 && i==0) || (k==dimension-1 && i==dimension-1) )
  62. {
  63. cout << " ";
  64. }
  65. else
  66. {
  67. cout << letra;
  68. }
  69. }
  70. cout << endl;
  71. }
  72. cout << endl << endl << endl;
  73.  
  74. ///////////////////
  75. // Circulo Vacio //
  76. ///////////////////
  77. for(int i=0; i<dimension; i++)
  78. {
  79. for(int k=0; k<dimension; k++)
  80. {
  81. if( (k==0 && i==0) || (k==0 && i==dimension-1) )
  82. {
  83. cout << " ";
  84. }
  85. else if( (k==dimension-1 && i==0) || (k==dimension-1 && i==dimension-1) )
  86. {
  87. cout << " ";
  88. }
  89. else if( (k>0 && i>0) && (k<dimension-1 && i<dimension-1))
  90. {
  91. cout << " ";
  92. }
  93. else
  94. {
  95. cout << letra;
  96. }
  97. }
  98. cout << endl;
  99. }
  100. cout << endl << endl << endl;
  101.  
  102.  
  103. return 0;
  104. }



Slds



En línea


Páginas: 1 [2] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
crear figuras en VB
Programación Visual Basic
Mr pom0 1 4,399 Último mensaje 26 Febrero 2008, 18:39 pm
por cassiani
[MOD] Representar figuras 3D en 2D
Java
Norbs 7 11,788 Último mensaje 8 Febrero 2009, 22:52 pm
por Amerikano|Cls
Como hacer figuras no convencionales con OpenGL ES?
Programación General
WHK 2 4,428 Último mensaje 15 Mayo 2015, 09:52 am
por BlackM4ster
Graficar 2 figuras 3D en Matlab al tiempo
Programación General
Daor02 0 1,594 Último mensaje 7 Abril 2017, 04:05 am
por Daor02
como hacer este barco con ciclos anidados ayuddaaaaa por favor
Programación C/C++
silfer_1908 2 2,414 Último mensaje 30 Septiembre 2018, 14:08 pm
por 3n31ch
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines