[luoyiran@luoyiran ~]$ vim do_while.c/*do...while语句,不管条件是否成立都要执行一遍循环语句*/#include<stdio.h> int main() { int a=0,c=0; do{ --c; a=a-1; }while(a>0); printf("c=%d\n",c); } [luoyiran@luoyiran ~]$ ./do_while c=-1
[luoyiran@luoyiran ~]$ vim while_do.c/*while…do,判断条件成立才会进入循环*/
#include<stdio.h>
int main() { int a=0,c=0; while(a>0) { --c; a=a-1; } printf("c=%d\n",c); } [luoyiran@luoyiran ~]$ ./while_do c=0