- ISBN号码
- 2010-07-13 20:39:08 @
#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 条评论
-
codeways LV 4 @ 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