首页 > 其他分享 >3.41 循环for与continue

3.41 循环for与continue

时间:2022-08-13 11:00:37浏览次数:74  
标签:main include 3.41 int continue printf total 循环

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main()
{
    //用for和continue实现奇数和

    int i, total;
    for (i = 1, total = 0; i <= 100; i++)
    {
        if (i % 2 == 0)
        {
            continue;
        }
        else
        {
            total += i;
            printf("当前i=%d\n", i);
            printf("当前total=%d\n", total);
        }
    }

    printf("100以内奇数total = %d\n", total);


    system("pause");
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main()
{
	//用for和continue实现奇数和

	int i, total;
	for (i = 1, total = 0; i <= 100; i++)
	{
		if (i % 2 == 0)
		{
			continue;
		}
		else
		{
			total += i;
			printf("当前i=%d\n", i);
			printf("当前total=%d\n", total);
		}
	}

	printf("100以内奇数total = %d\n", total);


	system("pause");
	return 0;
}

https://github.com/mzdbxwg/xiao/edit/main/3.41%E5%BE%AA%E7%8E%AFfor%E4%B8%8Econtinue.c

标签:main,include,3.41,int,continue,printf,total,循环
From: https://www.cnblogs.com/xwguo/p/16582331.html

相关文章