当前位置:网站首页>P1055 [noip2008 popularization group] ISBN number
P1055 [noip2008 popularization group] ISBN number
2022-07-02 10:54:00 【&volume】
Title Description
Every book officially published has a ISBN The number corresponds to ,ISBN Code includes 99 Digit number 、11 Bit ID and 33 Bit separator , The format is as follows x-xxx-xxxxx-x
, Symbols -
It's the separator ( The minus sign on the keyboard ), The last one is the identification number , for example 0-670-82162-4
It's a standard ISBN code .ISBN The first digit of the code indicates the language of publication of the book , for example 00 For English ; First separator -
The next three figures represent the publisher , for example 670670 On behalf of Viking press ; The five digits after the second separator represent the number of the book in the publishing house ; The last digit is the identification number .
The identification code is calculated as follows :
Multiply the first number by 11 Multiply the last digit by 22…… And so on , Use the results \bmod 11mod11, The remainder obtained is the identification code , If the remainder is 1010, The identification code is capital letters XX. for example ISBN number 0-670-82162-4
Identification code in 44 This is how I got : Yes 067082162
this 99 A digital , From left to right , Times, respectively, 1,2,...,91,2,...,9 And then sum up , namely 0×1+6×2+……+2×9=1580×1+6×2+……+2×9=158, And then take 158 \bmod 11158mod11 Result 44 As an identification number .
Your task is to write a program to judge the input ISBN Is the identification number correct , If correct , Only output Right
; If the error , Then output what you think is correct ISBN number .
Input format
A character sequence , For a book ISBN number ( Make sure the input matches ISBN Format requirements for number ).
Output format
a line , If you type ISBN The ID of the number is correct , Then output Right
, otherwise , In the prescribed form , Output correct ISBN number ( Include separator -
).
I/o sample
Input #1 Copy
0-670-82162-4
Output #1 Copy
Right
Input #2 Copy
0-670-82162-0
Output #2 Copy
0-670-82162-4
explain / Tips
2008 First question of popularization group
# 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;
}
}
边栏推荐
- Oracle notes
- 软件产品管理系统有哪些?12个最佳产品管理工具盘点
- Easyexcel, a concise, fast and memory saving excel processing tool
- [pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces
- 《实习报告》Skywalking分布式链路追踪?
- 快速做出原型
- Stm32 et développement de moteurs (système supérieur)
- 01-spooldir
- Redis set password
- Jsp webshell Free from killing - The Foundation of JSP
猜你喜欢
shell编程01_Shell基础
Retrofit's callback hell is really vulnerable in kotlin synergy mode!
Solutions to a series of problems in sqoop job creation
[visual studio] visual studio 2019 community version cmake development environment installation (download | install relevant components | create compilation execution project | error handling)
首份中国企业敏捷实践白皮书发布| 附完整下载
14. Code implementation of semaphore
Flutter环境配置保姆级教程,让doctor一绿到底
4. Random variables
axis设备的rtsp setup头中的url不能带参
Stm32 et développement de moteurs (système supérieur)
随机推荐
JSP webshell免殺——JSP的基礎
Read H264 parameters from mediarecord recording
MySQL lethal serial question 3 -- are you familiar with MySQL locks?
Oracle 笔记
(五)APA场景搭建之挡位控制设置
Kustomize使用手册
高考的意义是什么
STM32 and motor development (upper system)
AttributeError: type object ‘Image‘ has no attribute ‘fromarray‘
UVM learning - build a simple UVM verification platform
使用sqlcipher打开加密的sqlite方法
lunix重新分配root 和 home 空间内存
[unity3d] cannot correctly obtain the attribute value of recttransform, resulting in calculation error
UVM - configuration mechanism
点云投影图片
Windows环境MySQL8忘记密码文件解决方案
MySQL lethal serial question 4 -- are you familiar with MySQL logs?
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
【TS】1368- 秒懂 TypeScript 泛型工具类型!
12. Process synchronization and semaphore