1.打印100~200 之间的素数
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int a, i;
for (a = 101; a < 200; a++){
for (i = 2; i <= sqrt(a); i++){
if (a%i == 0){
break;
}
}
if (i>sqrt(a)){
printf("%d ", a);
}
}
printf("\n");
system("pause");
return 0;
}
2.输出乘法口诀表
#include<stdio.h>
#include<stdlib.h>
int main(){
int i, j, result;
for (i = 1; i <= 9; i++){
for (j = 1; j <= i; j++){
result = i*j;
printf("%d*%d=%d\t", j, i, result);
}
printf("\n");
}
system("pause");
return 0;
}
3.判断1000年---2000年之间的闰年
#include<stdio.h>
#include<stdlib.h>
int main(){
int year;
for (year = 1000; year <= 2000; year++){
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
printf("%d ", year);
}
printf("\n");
system("pause");
return 0;
}