一个简例
#include <stdio.h> int choose(); void eat(int, char*); void sleep(int); void hitdoudou(); int main() { int iChioce; do { iChioce=choose(); if (iChioce==1) eat(2, "鲜鱼"); else if (iChioce==2) sleep(30); else if (iChioce==3) hitdoudou(); else if (iChioce==0) break; else { printf("\007选择错误!\n"); continue; } printf("恭喜你完成了一项工作!\n\n"); } while(1); return 0; } int choose() { int i; printf("*请选择:\n"); printf("* 1. 吃饭\n"); printf("* 2. 睡觉\n"); printf("* 3. 打豆豆\n"); printf("* 0. 退出\n"); printf("* 请选择(0-3):"); scanf("%d", &i); return i; } void eat(int n, char *food) { printf("我吃了%d斤%s.\n", n, food); } void sleep(int m) { printf("我睡了%d分钟. \n", m); } void hitdoudou() { static int count = 0; count++; printf("打了%d次了.\n", count); }