for循环和while循环在使用continue时有所区别

#include "StdAfx.h"
#include 
using namespace std;

int main(void)
{
	int i=0;
	for (i=0; i<100; i++)
	{
		if (i==0)
		{
			continue;
		}
	}

	//while循环是死循环
	//int j=0;
	//while (j<100)
	//{
	//	if (j==0)
	//	{
	//		continue;
	//	}
	//	j++;
	//}
	system("pause");
	return 0;
}

 

使用continue时,for循环可以正常(i++可以执行到),while循环是个死循环。

你可能感兴趣的:(for循环和while循环在使用continue时有所区别)