Skip to content

Latest commit

 

History

History
29 lines (25 loc) · 302 Bytes

36.md

File metadata and controls

29 lines (25 loc) · 302 Bytes

题目:求100之内的素数。

#include<stdio.h>
#include <math.h>

int main()
{
	for (int i = 2; i <= 100; ++i)
	{
		int flag = 1;

		for (int j = 2; j <= sqrt(i); ++j)
		{
			if (i%j == 0)
			{
				flag = 0;
				break;
			}
		}

		if (flag)
		{
			printf("%d\n", i);
		}
	}

	return 0;
}