2 要求输出100~200之间的不能被3整除的数
1 2 3 4 | 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 |
其实不用 continue 也可以达到同样的效果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <stdio.h> #define SUM 100000 int main() { float amount,aver,total; int i; for (i=1,total=0; i<=1000; i++) { printf("please enter amount, student %4d = ", i); scanf("%f",&amount); total= total+amount; if (total>=SUM) break; } aver=total/i; printf("num=%dnaver=%10.2fn",i,aver); return 0; } |