终于过了...

#include

int main(void)

{

long a, b, c, d, result = -1, cnt;

if ((scanf("%ld-%ld-%ld-%ld", &a, &b, &c, &d)) == 4)

result = d;

cnt = ((a*1) + ((b/100)*2 + (b%100/10)*3 + (b%100%10)*4) +

((c/10000)*5 + (c%10000/1000)*6 + (c%10000%1000/100)*7 +

(c%10000%1000%100/10)*8 + (c%10000%1000%100%10)*9)) % 11;

if ((cnt == result) || (cnt == 10 && result == -1))

printf("Right\n");

else

printf("%ld-%ld-%ld-%c\n", a, b, c, cnt == 10 ? 'X' : cnt+'0');

return 0;

}

2 条评论

  • @ 2010-07-13 20:45:17

    上楼弄错了....这个最乱...

    #include

    int main(void)

    {

    long a, b, c, d, result = -1, cnt; if ((scanf("%ld-%ld-%ld-%ld", &a, &b, &c, &d)) == 4) result = d; cnt = ((a*1) + ((b/100)*2 + (b%100/10)*3 + (b%100%10)*4) +((c/10000)*5 + (c%10000/1000)*6 + (c%10000%1000/100)*7 +(c%10000%1000%100/10)*8 + (c%10000%1000%100%10)*9)) % 11; if ((cnt == result) || (cnt == 10 && result == -1)) printf("Right\n"); else printf("%ld-%ld-%ld-%c\n", a, b, c, cnt == 10 ? 'X' : cnt+'0'); return 0;

    }

  • @ 2010-07-13 20:40:57

    超乱代码全新登场~

    #include

    int main(void)

    {

    long a, b, c, d, result = -1, cnt;

    if ((scanf("%ld-%ld-%ld-%ld", &a, &b, &c, &d)) == 4) result = d;

    cnt = ((a*1) + ((b/100)*2 + (b%100/10)*3 + (b%100%10)*4) +((c/10000)*5 + (c%10000/1000)*6 + (c%10000%1000/100)*7 +(c%10000%1000%100/10)*8 + (c%10000%1000%100%10)*9)) % 11;

    if ((cnt == result) || (cnt == 10 && result == -1)) printf("Right\n");

    else printf("%ld-%ld-%ld-%c\n", a, b, c, cnt == 10 ? 'X' : cnt+'0');

    return 0;

    }

  • 1

信息

ID
1484
难度
5
分类
字符串 点击显示
标签
递交数
14462
已通过
4955
通过率
34%
被复制
33
上传者