|Tyvj|NOIP2008|模拟|P1006 isbn

来源:互联网 发布:路由器关闭了主人网络 编辑:程序博客网 时间:2024/05/13 13:04

http://tyvj.cn/p/1006

一道简单的水题,注意X即可

#include<cstdio>#include<cstring>#include<algorithm>using namespace std;char ch[80];int main () { scanf("%s", ch);int k = 0;int tot = 0;for (int i=0;i<11;i++){if (ch[i]>='0'&&ch[i]<='9'){tot += (++k)*(ch[i]-'0');}}tot %= 11;if ((tot==10&&ch[12]=='X')||(tot==ch[12]-'0')) {printf("Right");return 0;}else {for (int i=0;i<12;i++) putchar(ch[i]);if (tot==10) putchar('X'); else printf("%d", tot);}return 0;}


0 0
原创粉丝点击