c语言 8 - 5
1、
#include <stdio.h> enum info { Gender, Season, Age, Invalid}; void gender(void) { puts("male.\n"); } void season(void) { puts("summer.\n"); } void age(void) { puts("30.\n"); } enum info select(void) { enum info tmp; do { puts("0: gender 1: season 2: age 3: quit."); printf("tmp = "); scanf("%d", &tmp); } while(tmp < Gender || tmp > Invalid); return tmp; } int main(void) { enum info a; do { switch(a = select()) { case Gender : gender(); break; case Season : season(); break; case Age : age(); break; } } while(a != Invalid); return 0; }