#include<iostream>
using namespace std;
void main()
{
/*判断一个数是否能被3,5,7整除,以及整除的结果*/
cout<<"请输入一个数,判断其分别被3,5,7整除的情况:";
int a,s;
cin>>a;
s=((a%3==0?1:0)<<2)|((a%5==0?1:0)<<1)|(a%7==0?1:0);
cout<<s<<endl;
switch(s)
{
case 0:cout<<"不能被3,5,7整除\n";break;
case 1:cout<<"不能被3,5整除,能被7整除\n";break;
case 2:cout<<"不能被3,7整除,能被5整除\n";break;
case 3:cout<<"不能被3整除,能被5,7整除\n";break;
case 4:cout<<"不能被5,7整除,能被3整除\n";break;
case 5:cout<<"不能被5整除,能被3,7整除\n";break;
case 6:cout<<"不能被7整除,能被3,5整除\n";break;
case 7:cout<<"能被3,5,7整除\n";break;
}
}
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)