八十分求助

P1055 [NOIP2008 普及组] ISBN 号码

输入的也可能是X
by xingxing121 @ 2023-07-22 18:22:30


特别暴力写法如下: ```cpp #include <iostream> #include <cstdio> #include <string> #include <cstring> using namespace std; int main(){ int a,b,c; char d; int d1; scanf("%d-%d-%d-%c",&a,&b,&c,&d); if(d=='X'){ d1 = 10; }else{ d1 = d-'0';//转为数字 } int two = b/100; int three = b/10%10; int four = b%10; int five = c/10000; int six = c/1000%10; int seven = c/100%10; int eight = c/10%10; int nine = c%10; int sum = a+two*2+three*3+four*4+five*5+six*6+seven*7+eight*8+nine*9; if(sum%11==d1){ cout<<"Right"; }else if(sum%11==10){ printf("%d-%d-%d-X",a,b,c); }else{ printf("%d-%d-%d-%d",a,b,c,sum%11); } return 0; } ```
by xingxing121 @ 2023-07-22 18:23:08


好的,谢谢大佬
by ltzx2022_zhanghr_5 @ 2023-07-23 10:05:59


|