Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<stdlib.h>
- #include<Windows.h>
- #include<time.h>
- void main()
- {
- int positionT = 1, positionH = 1, moveT, moveH, row, width;
- //random seed for nonrepeating randomness
- srand(clock_t());
- do {
- system("cls");
- printf("||*****TORTOISE AND THE HARE*****||\n\n");
- printf("BANG !!!!!\nAND OFF THEY GO !!!!\n\n");
- moveT = rand() % 10 + 1;
- if (moveT <= 5)
- //removed semicolon
- moveT = 3;
- else if (moveT <= 7)
- //changed to else if
- moveT -= 6;
- else
- moveT = 1;
- moveH = rand() % 10 + 1;
- if (moveH <= 2)
- moveH = 0;
- else if (moveH <= 4)
- moveH = 9;
- else if (moveH == 5)
- moveH = -12;
- else if (moveH <= 8)
- moveH = 1;
- else
- moveH = 2;
- positionT += moveT;
- positionH += moveH;
- //Reset function
- if (positionT < 1) positionT = 1;
- if (positionH < 1) positionH = 1;
- //In case of negative position
- if (positionT == positionH)
- printf("\nOOOUUCCHHH!!!!");
- for (row = 2; row; row--)
- {
- for (width = 71; width; width--) printf("-");
- printf("\n");
- for (width = 71; width; width--)
- if ((width % 2) == 0)
- //restored to origignal code
- if (((positionT > 35 && row == 2) && (width / 2 == positionT - 35)) || ((positionT <= 35 && row == 1) && (width / 2 == positionT))) printf("T");
- //restored to origignal code
- else printf(" ");
- else printf("|");
- printf("\n");
- for (width = 71; width; width--)
- if ((width % 2) == 0)
- //restored to original code
- if (((positionH > 35 && row == 2) && (width / 2 == positionH - 35)) || ((positionH <= 35 && row == 1) && (width / 2 == positionH))) printf("H");
- //restored to original code
- else printf(" ");
- else printf("|");
- printf("\n");
- for (width = 71; width; width--) printf("-");
- printf("\n");
- printf("\n");
- }
- Sleep(1000);
- //break;
- } while ((positionT < 70) && (positionH < 70));
- if ((positionT >= 70) && (positionH >= 70))
- printf("\nIT'S A TIE!!!");
- if (positionT >= 70)
- printf("\nTORTOISE WON THE RACE!!!");
- else
- printf("\nHARE WON THE RACE!!!");
- _getch();
- }//end program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement