题解 | #牛牛的二三七整除#
牛牛的二三七整除
https://www.nowcoder.com/practice/b2cf0b791245436f8f0591ae9f4c664f
#include <iostream> #include <string> using namespace std; int main() { int a; while (cin >> a) { // 注意 while 处理多个 case string b=""; if(a%2==0) { b+="2 "; } if(a%3==0) { b+="3 "; } if(a%7==0) { b+="7 "; } if(b=="") { b+="n"; } cout<<b; } } // 64 位输出请用 printf("%lld")
这种题也可以使用字符串来判断是否为空