打印100 ~ 200之间的素数

素数为被1和其本身整除的数字,称为素数。
简单的实现(当然还有别的方法可以完成)
源代码:

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

int main(){	
	int i = 0, j = 0;
	for (i = 100; i < 201; i++){	
		
		for (j = 2; j < i; j++){
		
			if (i%j == 0)
				break;
		}
		if (j == i)
			printf("%d ", i);
	}
	printf("\n");
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/tomatolee221/article/details/84729389