1、#include stdio.hint main(void){int i;do{puts(please input the i value.);printf(i = ); scanf(%d, i);if (i 0 || i 2)puts(the span value of i is 0~3);}while (i 0 || i 2); ## 当...

1、
#include <stdio.h> int main(void) { int i; do { puts("please input the i value."); printf("i = "); scanf("%d", &i); if (i < 0 || i > 2) puts("the span value of i is 0~3"); } while (i < 0 || i > 2); ## 当输入的i的值小于0或者大于2的则判断为非0,程序循环。 switch(i) ## switch语句分支结构判断 { case 0: puts("stone!"); break; case 1: puts("scissors"); break; case 2: puts("clothes"); break; } return 0; }
沃梦达教程
本文标题为:c语言中循环控制语句(do语句),锁定输入值的范围


基础教程推荐
猜你喜欢
- C语言 structural body结构体详解用法 2022-12-06
- 一文带你了解C++中的字符替换方法 2023-07-20
- C++详细实现完整图书管理功能 2023-04-04
- 详解c# Emit技术 2023-03-25
- C++使用easyX库实现三星环绕效果流程详解 2023-06-26
- C/C++编程中const的使用详解 2023-03-26
- 如何C++使用模板特化功能 2023-03-05
- C利用语言实现数据结构之队列 2022-11-22
- C++中的atoi 函数简介 2023-01-05
- C语言基础全局变量与局部变量教程详解 2022-12-31