C语言打印100以内的质数
#include <stdio.h> int main() { int number; int divisor; for( number = 3; number <= 100; number += 2 ) { for( divisor = 3; divisor <= number; divisor += 2 ) { if( number % divisor == 0 ) break; } if( divisor == number ) printf("%d\n",number); } return EXIT_SUCCESS; }
时间: 2024-10-12 14:30:23