当前位置:网站首页>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;
}
}
边栏推荐
- 转换YV12到RGB565图像转换,附YUV转RGB测试
- stm32和电机开发(上位系统)
- [Lua] summary of common knowledge points (including common interview sites)
- [visual studio] every time you open a script of unity3d, a new vs2017 will be automatically reopened
- [Fantasy 4] introduction and use of UMG components (under update...)
- 数据库字典Navicat自动生成版本
- Webui automated learning
- In the face of uncertainty, the role of supply chain
- 高考的意义是什么
- js promise.all
猜你喜欢
Use WinDbg to statically analyze dump files (summary of practical experience)
VLAN experiment
07 data import sqoop
Allure -- common configuration items
stm32和电机开发(上位系统)
Disassembling Meitu SaaS: driving the plane to change the engine
JSP webshell免杀——webshell免杀
Thanos Receiver
SUS系统可用性量表
Flutter环境配置保姆级教程,让doctor一绿到底
随机推荐
[unity3d] nested use layout group to make scroll view with dynamic sub object height
长投学堂上面的账户安全吗?
AttributeError: type object ‘Image‘ has no attribute ‘fromarray‘
MYSQL环境配置
The nanny level tutorial of flutter environment configuration makes the doctor green to the end
Open the encrypted SQLite method with sqlcipher
[tutorial] how to make the Helpviewer help document of VisualStudio run independently
Flutter——Canvas自定义曲线图
618 what is the secret of dominating the list again? Nike's latest financial report gives the answer
KS009基于SSH实现宠物管理系统
STM32 and motor development (upper system)
MySQL数据库远程访问权限设置
从MediaRecord录像中读取H264参数
Flutter环境配置保姆级教程,让doctor一绿到底
Shapiro Wilk normal analysis by SPSS
4.随机变量
4. Random variables
Introduction to MySQL 8 DBA foundation tutorial
Pywin32打开指定窗口
Pytest-- test report allure configuration