2_9.cpp
上传用户:zipjojo
上传日期:2009-07-20
资源大小:70k
文件大小:1k
- #include <iostream.h>
- void main()
- {
- int x,j=0;
-
- do
- {
- cout<<"Input a number:";
- cin>>x;
-
- if ((x%3==0) && (x%5==0) && (x%7==0))
- cout<<endl<<x<<" can be devided by 3,5 and 7."<<endl;
- else
- if (x%3==0)
- if (x%5==0)
- cout<<endl<<x<<" can be devided by 3 and 5."<<endl;
- else
- if (x%7==0)
- cout<<endl<<x<<" can be devided by 3 and 7."<<endl;
- else
- cout<<endl<<x<<" can be devided by 3."<<endl;
- else
- if (x%5==0)
- if (x%7==0)
- cout<<endl<<x<<" can be devided by 5 and 7."<<endl;
- else
- cout<<endl<<x<<" can be devided by 5."<<endl;
- else
- if (x%7==0)
- cout<<endl<<x<<" can be devided by 7."<<endl;
- else
- cout<<endl<<x<<" cann't be devided by 3,5 or 7."<<endl;
- j++;
- }while (j<=2);
- }