希丰展?使MD
by Rieman_sum @ 2023-08-07 19:48:53
@[Guo1](/user/743879) 呃确实这……
by Max6700 @ 2023-08-07 19:52:31
@[17688928372ding](/user/782437) MD炸了
by yzm0325 @ 2023-08-07 19:53:02
不用if里面套if,有什么输出什么即可
```
#include<bits/stdc++.h>
using namespace std;
int x,f=0;
int main(){
cin>>x;
if(x%3==0){
f=1;//如果x能被整除那么f+1,f用来判断三个条件的成立
cout<<"3 ";
}
if(x%5==0){
f=1;
cout<<"5 ";//if判断是从小到大比的,不需要比大小
}
if(x%7==0){
f=1;
cout<<"7 ";
}
if(f==0){//三个条件都没成立,f就=0 输出n;
cout<<"n";
}
return 0;
}
```
by Tairitsu_Cat @ 2023-08-12 18:26:43
AC代码:
```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
if(n%3==0 && n%5==0 && n%7==0) cout<<"3"<<" "<<"5"<<" "<<"7";
if(n%3==0 && n%5==0 && n%7!=0) cout<<"3"<<" "<<"5";
if(n%3==0 && n%5!=0 && n%7==0) cout<<"3"<<" "<<"7";
if(n%3!=0 && n%5==0 && n%7==0) cout<<"5"<<" "<<"7";
if(n%3==0 && n%5!=0 && n%7!=0) cout<<"3";
if(n%3!=0 && n%5==0 && n%7!=0) cout<<"5";
if(n%3!=0 && n%5!=0 && n%7==0) cout<<"7";
return 0;
}
```
by quxiangyu @ 2024-01-24 18:15:05