Guest User

Untitled

a guest
Jun 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void Intro_Primera (char c[4][4]);
  5. void tablero (char c[4][4]);
  6. void sorteo (int a, char c[4][4]);
  7. void partida (char c[4][4],int juego);
  8.  
  9. int main ()
  10. {
  11. int a;
  12. char c [4][4];
  13. char d [3][3];
  14. printf ("......Bienvenido al Juego TA-TE-TI......nn");
  15. Intro_Primera (c);
  16. tablero (c);
  17. sorteo (a,c);
  18.  
  19. }
  20.  
  21. void Intro_Primera (char c [4][4])
  22. {
  23. int i,j;
  24. char a={'.'};
  25. for (i=0;i<4;i++)
  26. {
  27. for (j=0;j<4;j++)
  28. {
  29.  
  30.  
  31. if (i==0)
  32. {
  33. if (j==0)
  34. c[i][j]=(' ');
  35. else if (j==1)
  36. c[i][j]=('A');
  37. else if (j==2)
  38. c[i][j]=('B');
  39. else if (j==3)
  40. c[i][j]=('C');
  41.  
  42. }
  43. else
  44. c[i][j]= a;
  45.  
  46. if (i==1 & j==0)
  47. c[i][j]=('1');
  48. else if (i==2 & j==0)
  49. c[i][j]=('2');
  50. else if (i==3 & j==0)
  51. c[i][j]=('3');
  52. }
  53.  
  54. }
  55. }
  56.  
  57. void tablero (char c[4][4])
  58. {
  59. int i,j;
  60. for (i=0; i<4; i++)
  61. {
  62. for (j=0; j<4; j++)
  63. {
  64. if (j<3)
  65. {
  66. printf (" %c |",c[i][j]);
  67. }
  68. else
  69. {
  70. printf (" %c ",c[i][j]);
  71. }
  72. }
  73. if (i<3)
  74. {
  75. printf ("n--------------n");
  76. }
  77. }
  78. printf ("nn");
  79. }
  80.  
  81. void sorteo (int a,char c[4][4])
  82. {
  83. int juego=0;
  84. srand (time(NULL));
  85. int n=rand()% 2;
  86. if (n==0)
  87. {
  88. printf ("Usted comienza el JuegonnUsted empieza jugando con la Xn");
  89. juego=0;
  90. partida(c,juego);
  91.  
  92. }
  93. else
  94. {
  95. printf ("La Computadora comienza el JuegonnUsted empieza jugando con la On");
  96. juego=1;
  97. }
  98. }
  99.  
  100. void partida (char c[4][4],int juego)
  101. {
  102. char a;
  103. int i,j;
  104. if (juego==0)
  105. {
  106. for (i=0; i<9;i++)
  107. {
  108. printf ("Ingrese las Coordenadasn");
  109. scanf("%c",&a);
  110. if(a=='1A')
  111. c[1][1]='X';
  112. else if (a=='2A')
  113. c[2][1]='X';
  114. else if (a=='3A')
  115. c[3][1]='X';
  116. else if (a=='1B')
  117. c[1][2]='X';
  118. else if (a=='2B')
  119. c[2][2]='X';
  120. else if (a=='3B')
  121. c[3][2]='X';
  122. else if (a=='1C')
  123. c[1][3]='X';
  124. else if (a=='2C')
  125. c[2][3]='X';
  126. else if (a=='3C')
  127. c[3][3]='X';
  128. tablero (c);
  129.  
  130. }
  131. }
  132. }
Add Comment
Please, Sign In to add comment