题解 | #牛牛的素数判断#
牛牛的素数判断
https://www.nowcoder.com/practice/81c8387f72824cceb5c955e3dbfd2882
#include <stdio.h> int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int num;//要重新定义一个数 scanf("%d", &num); int flag = 1;//标记 for (int j = 2; j < num; j++) { if (num % j == 0) { flag = 0; break; } } if (flag == 1) { printf("true\n"); } else { printf("false\n"); } } return 0; }