c語言中循環控制語句(do語句,限制用戶輸入數值的范圍)
1、
#include <stdio.h>
int main(void) { int i; do { puts("please input an integer! the range is 0-2!"); printf("i = "); scanf("%d", &i); } while (i < 0 || i > 2); ## 此句判斷為非0,則繼續執行循環體 switch (i) { case 0: puts("you had choose stone!"); break; case 1: puts("you had choose scissors!"); break; case 2: puts("you had choose clothes!"); break; } return 0; }