题解 | #挑7#

挑7

http://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b

#include <stdio.h>

int main()
{
    int num = 0;
    int count = 0;
    scanf("%d", &num);
    if(num >= 1 && num <= 30000)
    {
        for(int i = num; i > 0; i--)
        {
            if(i % 7 == 0 
               || i % 10 == 7 		/* 取个位 */
               || (i / 10) % 10 == 7 		/* 取十位 */
               || (i / 100) % 10 == 7 		/* 取百位 */
               || (i / 1000) % 10 == 7		/* 取千位 */
               || (i / 10000) % 10 == 7)	/* 取万位 */
            {
                count++;
            }
        }
        printf("%d\n", count);
    }
    return 0;
}
全部评论

相关推荐

07-01 13:37
门头沟学院 Java
steelhead:不是你的问题,这是社会的问题。
点赞 评论 收藏
分享
07-01 17:14
中北大学 Java
兄弟们是真是假
牛客46374834...:我在boss上投java岗从来没成功过
点赞 评论 收藏
分享
评论
5
2
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务