蒟蒻求调

P1055 [NOIP2008 普及组] ISBN 号码

上原码 ```cpp #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<algorithm> #include<cstdlib> #include<queue> using namespace std; int main() { char a[14]; scanf("%s",a); int j=1,t=0; for(int i=0;i<12;i++) { if(a[i]=='-') { continue; } t+=(a[i]-'0')*j++; } t=t%11; if(t+'0'==a[12]) { printf("Right"); } else if(t==10&&a[12]=='X') { printf("Right"); } else { if(t==10) { a[12]='X'; printf("%s",a); } else if(t<10) { a[12]=t+'0'; printf("%s",a); } } return 0; } ```
by Continu @ 2023-10-05 20:38:24


@[Subset](/user/1069779) 字符串的输入不能用scanf,只能用cin ```cpp 需要头文件#include<iostream> ``` 或 gets() ```cpp 需要头文件#include<string> ``` 如果一定要用scanf,则要将字符串先转换为字符数组
by Continu @ 2023-10-05 20:50:02


谢谢,此帖结
by Subset @ 2023-10-05 20:51:26


|