今天无聊,想想自己还从还没在这发过主题,所以乱写了一个小东西
呵呵 是个猜数赌博的小游戏
#include <stdlib.h> #include <stdio.h> #include <time.h>
int main(void) { int c,d,a; int money=10; printf("Welcome to play Guess-Guess!\n"); printf("Now you have 1 yuan.^_^\nMoney=1 yuan\n"); do { randomize(); c=random(10); printf("Please input the number you guess(From 0-9): "); scanf("%d",&d); printf("The random number is %d .\n",c); if(c==d) {money=money+1; printf("Congatulates!^_^\n"); printf("Now you have %d yuan.",money); printf("Try again? Please choose 0 or 1.(0-No; 1-Yes)\n"); scanf("%d",&a); if(a==1) printf("You choose Yes and the game will go on^_^.\n"); else printf("Bye-Bye!"); } else {money=money-1; printf("Sorry,YOU LOSE.\n"); if(money==0) {printf("Now you have no money.@_@\nGame over! Bye!"); a=0;
} else {printf("Now you still have %d yuan. Go on? ",money); printf("Please choose 0 or 1.(0-No; 1-Yes)\n"); scanf("%d",&a); if(a==1) printf("You choose Yes and the game will go on^_^.\n"); else printf("Bye-Bye!"); } }
printf("\n\n"); }while(a==1);
getch(); return 0; }