The author has 2 posts.
Font size: Small - 100% (Default)  Content converter: No conversion
 
Clicks Replies
994 1
【试题】回文数字
巨大八爪鱼
武林盟主 二十一级
Reply
Floor 1 Posted at: 3/13/16 22:27
#include <stdio.h>

int main(void)
{
    int n, i;
    int a, b, c, d, e, f;
    int count = 0;
    scanf("%d", &n);
    for (i = 10000; i < 999999; i++)
    {
        a = i / 100000;
        b = i % 100000 / 10000;
        c = i % 10000 / 1000;
        d = i % 1000 / 100;
        e = i % 100 / 10;
        f = i % 10;
        if (a + b + c + d + e + f == n)
        {
            if ((a == 0 && b == f && c == e) || (a != 0 && a == f && b == e && c == d))
            {
                count++;
                printf("%d\n", i);
            }
        }
    }
    if (count == 0)
        puts("-1");
    return 0;
}
巨大八爪鱼
武林盟主 二十一级
Reply
Floor 2 Posted at: 3/13/16 22:27
正确  100  31ms  1.605MB  
Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.
(Shortcut key: Ctrl+Enter)
Post Information
Clicks: 994 Replies: 1
Author: 巨大八爪鱼
Last reply: 巨大八爪鱼
Last reply time: 3/13/16 22:27
Announcements