题解 | 判断一个数是不是质数
#include <iostream> using namespace std; int main() { // write your code here...... int n, num = 0; cin >> n; for (int i = 2; i < n; i++){ if (n % i == 0){ num = 1; cout << "不是质数" << endl; break; } } if (num == 0){ cout << "是质数" << endl; } return 0; }