C语言编程:测试整数n是否包含数字5(n由键盘输入),若包含数字5,则输出YES,否则输出NO (C程序)
#include <STDIO.H>
int main(void)
{
int num;
printf("number:");
scanf("%d",&num);
while(num != 0)
{
if(num%10 == 5)
{
printf("YES\n");
return 0;
}
num /= 10;
}
printf("NO\n");
return 0;
}
int main(void)
{
int num;
printf("number:");
scanf("%d",&num);
while(num != 0)
{
if(num%10 == 5)
{
printf("YES\n");
return 0;
}
num /= 10;
}
printf("NO\n");
return 0;
}
温馨提示:答案为网友推荐,仅供参考