当前位置:网站首页>P1055 [NOIP2008 普及组] ISBN 号码
P1055 [NOIP2008 普及组] ISBN 号码
2022-07-02 07:06:00 【&volume】
题目描述
每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括99位数字、11位识别码和33位分隔符,其规定格式如x-xxx-xxxxx-x,其中符号-就是分隔符(键盘上的减号),最后一位是识别码,例如0-670-82162-4就是一个标准的ISBN码。ISBN码的首位数字表示书籍的出版语言,例如00代表英语;第一个分隔符-之后的三位数字代表出版社,例如670670代表维京出版社;第二个分隔符后的五位数字代表该书在该出版社的编号;最后一位为识别码。
识别码的计算方法如下:
首位数字乘以11加上次位数字乘以22……以此类推,用所得的结果\bmod 11mod11,所得的余数即为识别码,如果余数为1010,则识别码为大写字母XX。例如ISBN号码0-670-82162-4中的识别码44是这样得到的:对067082162这99个数字,从左至右,分别乘以1,2,...,91,2,...,9再求和,即0×1+6×2+……+2×9=1580×1+6×2+……+2×9=158,然后取158 \bmod 11158mod11的结果44作为识别码。
你的任务是编写程序判断输入的ISBN号码中识别码是否正确,如果正确,则仅输出Right;如果错误,则输出你认为是正确的ISBN号码。
输入格式
一个字符序列,表示一本书的ISBN号码(保证输入符合ISBN号码的格式要求)。
输出格式
一行,假如输入的ISBN号码的识别码正确,那么输出Right,否则,按照规定的格式,输出正确的ISBN号码(包括分隔符-)。
输入输出样例
输入 #1复制
0-670-82162-4
输出 #1复制
Right
输入 #2复制
0-670-82162-0
输出 #2复制
0-670-82162-4
说明/提示
2008普及组第一题
# include <iostream>
//# include <stdlib>
using namespace std;
int main()
{
// string s;
// cin>>s;
char s[13];
for(int i=0;i<=12;i++)
{
cin>>s[i];
}
int j=1,i=0,n=0;
for(i=0;i<12;i++)
{
if(s[i]>47&&s[i]<58)
{
int a=0;
a=(int)s[i];
//printf("%d\n",a);
n=(a-48)*j+n;
++j;
}
}
if(n%11==s[12]-48||(n%11==10&&s[12]=='X'))
{
cout<<"Right";
}
else
{
// if(s[12]=='X'&&s[12])
for(int i=0;i<12;i++)
{
cout<<s[i];
}
if(n%11==10)
cout<<"X";
else
cout<<n%11;
}
}
边栏推荐
- Dialogue Wu Gang: why do I believe in the rise of "big country brands"?
- 1287_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
- Post disaster reconstruction -- Floyd thought
- Win11 arm系统配置.net core环境变量
- [unity3d] nested use layout group to make scroll view with dynamic sub object height
- 《MySQL 8 DBA基础教程》简介
- JS settimeout() and interview questions
- JSP webshell免杀——webshell免杀
- nodejs+express+mysql简单博客搭建
- flume 190 INSTALL
猜你喜欢
随机推荐
MPLS experiment
01-spooldir
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
转换YV12到RGB565图像转换,附YUV转RGB测试
Database dictionary Navicat automatic generation version
Stm32 et développement de moteurs (système supérieur)
MySQL数据库远程访问权限设置
07数据导入Sqoop
[MySQL] an exception occurs when connecting to MySQL: connection must be valid and open
4.随机变量
js promise.all
Flutter——Canvas自定义曲线图
VLAN experiment
JS settimeout() and interview questions
Network communication learning
Transport Optimization abstraction
MYSQL关键字
Shutter - canvas custom graph
SQOOP 1.4.6 INSTALL
07 data import sqoop

![2.hacking-lab脚本关[详细writeup]](/img/f3/29745761cd5ad4df84c78ac904ea51.png)
![[visual studio] every time you open a script of unity3d, a new vs2017 will be automatically reopened](/img/c3/aec0a9fb79cf94b3575d95530aa8e8.png)






