Description
一个正整数,如果它能被7整除,或者它的十进制(decimal)表示法中某位上的数字为7,则称其为与7相关的数。现判断输入的某个数是否与7有关,有则输出 YES ,无则输出 NO 。
Input
测试数据有多组,一组一行,当输入为0时结束。每行是一个正整数 n ( n < 100 )。
Output
对每个测试数据,输出相应的一行结果: YES 或 NO
Sample Input
21
10
7
0
Sample Output
YES
NO
YES
代码如下:
#include<stdio.h>
int main()
{
int n;
while(scanf("%d",&n)==1&&n!=0)
{
if(n%7==0||n%10==7||n/10%10==7)
{
printf("YES\n");
}else{
printf("NO\n");
}
}
return 0;
}