//打印閏年 #include <stdio.h> int main() { int year = 0; int count = 0; for (year = 1000;year <= 2000;year++) { if (year%4==0 && year%100!=0) { printf("%d ", year); count++; } else if (year % 400 == 0) { printf("%d ", year); count++; } } printf("\ncount=%d\n ",count); return 0; }
//打印素數ide
#include <stdio.h> int main() { int i = 0; int j = 0; int count = 0; for (i=100;i<=200;i++) { for (j = 2;j < i;j++) { if (i%j == 0) break; } if (j == i) { count++; printf("%d ",i); } } printf("\ncount=%d\n ",count); return 0; }
//code