当前位置:网站首页>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;
}
}
边栏推荐
- 面对不确定性,供应链的作用
- 网络通信学习
- [pit avoidance guide] pit encountered by unity3d project when accessing Tencent bugly tool
- Start class, data analysis, high salary training plan, elite class
- Windows环境MySQL8忘记密码文件解决方案
- KS009基于SSH实现宠物管理系统
- The URL in the RTSP setup header of the axis device cannot take a parameter
- 2021-10-02
- 02-taildir source
- 从MediaRecord录像中读取H264参数
猜你喜欢
随机推荐
MYSQL关键字
[unity3d] nested use layout group to make scroll view with dynamic sub object height
2.hacking-lab脚本关[详细writeup]
Allure -- common configuration items
记录 AttributeError: ‘NoneType‘ object has no attribute ‘nextcall‘
12. Process synchronization and semaphore
Redis set password
《MySQL 8 DBA基础教程》简介
1287_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
AI技术产业热点分析
01 install virtual machine
Importing tables from sqoop
UVM learning - build a simple UVM verification platform
Retrofit's callback hell is really vulnerable in kotlin synergy mode!
网络通信学习
"Matching" is true love, a new attitude for young people to make friends
Basic usage of mock server
1287_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
What are the popular frameworks for swoole in 2022?
Internet News: Tencent conference application market was officially launched; Soul went to Hong Kong to submit the listing application









