C语言基础:for从大到小循环语句范例
#include <stdio.h> int main () { int counter; for (counter = 5; counter >= 1; counter--) printf("%d ", counter); printf("\nStarting second loop\n"); for (counter = 10; counter >= 1; counter--) printf("%d ", counter); printf("\nStarting third loop\n"); for (counter = 0; counter >= 1; counter--) printf("%d ", counter); return 1; }
gcc编译运行结果
5 4 3 2 1 Starting second loop 10 9 8 7 6 5 4 3 2 1 Starting third loop