第一题:
#include
int not_prime(int x)
{
int i = 0;
for(i = 2; i
}
int main(void)
{
int i = 0, j = 0;
for(i = 2; i < 100; i++) {
if(not_prime(i)) continue;
printf("%d ", i);
if(++j % 5 ==0) printf("\n");
}
return 0;
}
/*
运行结果:
2 3 4 5 7
11 13 17 19 23
29 31 37 41 43
47 53 59 61 67
71 73 79 83 89
97
*/
第二题:
#include
int main(void)
{
int x=0, y = 0;
for(;;) {
printf("请输入两个非零整数:");
scanf("%d %d", &x, &y);
if(x == 0 || y == 0) continue;
printf("%d + %d = %d\n%d - %d = %d\n%d * %d = %d\n%d / %d = %f\n", x, y, x+y, x, y, x-y, x, y, x * y, x, y, (float)x/(float)y);
break;
}
return 0;
}