Problem4592--判断 能否被 3 , 5 , 7 整除

4592: 判断 能否被 3 , 5 , 7 整除

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description

给定一个整数x,判断它能否被3,5,7整除,并输出以下信息:

1.不能被任何数整除,输出小写字符n

2.能同时被3,5,7整除(直接输出3 5 7,每个数中间一个空格);

3.只能被其中两个数整除(按从小到大的顺序输出两个数,例如:3 5或者3 7或者5 7,中间用空格分隔);

4.只能被其中一个数整除(输出这个除数);请同学们补全这个程序并提交。

#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    //如果既不能被 3 也不能被 5 也不能被 7 整除
    if (_______________________) 
        cout << "n";
    if (____) cout << "3 ";
    if (____) cout << "5 ";
    if (____) cout << "7 ";
    return 0;
}

Sample Input Copy

105

Sample Output Copy

3 5 7

Source/Category