Advertisement
BladeMechanics

Debugged T_H

Sep 11th, 2017
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.12 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. #include<Windows.h>
  5. #include<time.h>
  6.  
  7.  
  8. void main()
  9. {
  10.  
  11.     int positionT = 1, positionH = 1, moveT, moveH, row, width;
  12. //random seed for nonrepeating randomness
  13.     srand(clock_t());
  14.  
  15.     do {
  16.         system("cls");
  17.         printf("||*****TORTOISE AND THE HARE*****||\n\n");
  18.         printf("BANG !!!!!\nAND OFF THEY GO !!!!\n\n");
  19.  
  20.         moveT = rand() % 10 + 1;
  21.         if (moveT <= 5)
  22. //removed semicolon
  23.             moveT = 3;
  24.         else if (moveT <= 7)
  25. //changed to else if
  26.             moveT -= 6;
  27.         else
  28.             moveT = 1;
  29.  
  30.         moveH = rand() % 10 + 1;
  31.         if (moveH <= 2)
  32.             moveH = 0;
  33.         else if (moveH <= 4)
  34.             moveH = 9;
  35.         else if (moveH == 5)
  36.             moveH = -12;
  37.         else if (moveH <= 8)
  38.             moveH = 1;
  39.         else
  40.             moveH = 2;
  41.  
  42.         positionT += moveT;
  43.         positionH += moveH;
  44. //Reset function       
  45.         if (positionT < 1) positionT = 1;
  46.         if (positionH < 1) positionH = 1;
  47. //In case of negative position
  48.         if (positionT == positionH)
  49.             printf("\nOOOUUCCHHH!!!!");
  50.  
  51.         for (row = 2; row; row--)
  52.         {
  53.  
  54.             for (width = 71; width; width--) printf("-");
  55.             printf("\n");
  56.             for (width = 71; width; width--)
  57.                 if ((width % 2) == 0)
  58. //restored to origignal code
  59.                     if (((positionT > 35 && row == 2) && (width / 2 == positionT - 35)) || ((positionT <= 35 && row == 1) && (width / 2 == positionT))) printf("T");
  60. //restored to origignal code
  61.                     else printf(" ");
  62.                 else printf("|");
  63.                 printf("\n");
  64.                 for (width = 71; width; width--)
  65.                     if ((width % 2) == 0)
  66. //restored to original code
  67.                         if (((positionH > 35 && row == 2) && (width / 2 == positionH - 35)) || ((positionH <= 35 && row == 1) && (width / 2 == positionH))) printf("H");
  68. //restored to original code
  69.                         else printf(" ");
  70.                     else printf("|");
  71.                     printf("\n");
  72.                     for (width = 71; width; width--) printf("-");
  73.                     printf("\n");
  74.  
  75.                     printf("\n");
  76.         }
  77.         Sleep(1000);
  78.         //break;
  79.     } while ((positionT < 70) && (positionH < 70));
  80.  
  81.  
  82.     if ((positionT >= 70) && (positionH >= 70))
  83.         printf("\nIT'S A TIE!!!");
  84.     if (positionT >= 70)
  85.         printf("\nTORTOISE WON THE RACE!!!");
  86.     else
  87.         printf("\nHARE WON THE RACE!!!");
  88.     _getch();
  89.  
  90. }//end program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement