Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <math.h>
- #include <time.h> //for the rand() seeding randomness
- int main()
- {
- srand ( time(NULL) );
- int dice1, dice2, dice3;
- int dicea, diceb, dicec;
- char a, h, l, s;
- int sum1, sum2;
- dice1 = ( rand()%6 ) +1;
- dice2 = ( rand()%6 ) +1;
- dice3 = ( rand()%6 ) +1;
- sum1 = dice1 + dice2 + dice3;
- printf("--------------------------------\n");
- printf(" First dice: %d\n", dice1);
- printf(" Second dice: %d\n", dice2);
- printf(" Third dice: %d\n", dice3);
- printf(" The sum of the 3 dice is %d.\n", sum1);
- printf("--------------------------------\n");
- printf("Guess if the next sum will be higher(h), lower(l) or the same(s).\n");
- scanf(" %c", &a);
- dicea = ( rand()%6 ) +1;
- diceb = ( rand()%6 ) +1;
- dicec = ( rand()%6 ) +1;
- sum2 = dicea + diceb + dicec;
- printf("--------------------------------\n");
- printf(" First dice: %d\n", dicea);
- printf(" Second dice: %d\n", diceb);
- printf(" Third dice: %d\n", dicec);
- printf(" The second sum is %d!\n", sum2);
- printf("--------------------------------\n");
- if(a == 'h' && sum2>sum1) {
- printf("Congrats!\n");
- }else {
- if(a == 'h' && sum2<=sum1) { printf("You suck!");
- }
- }
- if(a == 'l' && sum2<sum1) {
- printf("Congrats!\n");
- }else {
- if(a == 'l' && sum2>=sum1) {printf("You suck!");
- }
- }
- if(a == 's' && sum2 == sum1) {
- printf("Congrats!\n");
- }else{
- if(a == 's' && sum2 !=sum1) {printf("You suck!");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement