c语言中多重循环

 

#include <stdio.h>

int main(void)
{
    int label;
    do
    {
        int i;
        do
        {
            puts("please input an integer.");
            printf("i = "); scanf("%d", &i);
            if (i <= 0)
                printf("\a please input an + integer.");
        } while (i <= 0);
        
        int j;
        for (j = 1; j <= i; j ++ )
        {
            printf("%d\n", j);
        }
        puts("please input label 0 to continue or other to continue.");
        printf("label = "); scanf("%d", &label);
    } while (label == 0);
    return 0;
}

 

posted @ 2021-01-07 23:57  小鲨鱼2018  阅读(229)  评论(0编辑  收藏  举报