当前位置:网站首页>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;
}
}
边栏推荐
- 转换YV12到RGB565图像转换,附YUV转RGB测试
- Database dictionary Navicat automatic generation version
- flume 190 INSTALL
- Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
- 01 install virtual machine
- 14.信号量的代码实现
- Win11 arm系统配置.net core环境变量
- lunix重新分配root 和 home 空间内存
- Kustomize user manual
- 【TS】1368- 秒懂 TypeScript 泛型工具类型!
猜你喜欢

Database dictionary Navicat automatic generation version

HDU1234 开门人和关门人(水题)

(五)APA场景搭建之挡位控制设置

Redis set password

HDU1228 A + B(map映射)

Stm32 et développement de moteurs (système supérieur)

The URL in the RTSP setup header of the axis device cannot take a parameter

1287_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
![[Fantasy 4] the transformation from U3D to UE4](/img/bb/665eba3c8cd774c94fe14f169121da.png)
[Fantasy 4] the transformation from U3D to UE4

2022-06-17
随机推荐
lunix重新分配root 和 home 空间内存
PCL 从一个点云中提取一个子集
stm32和電機開發(上比特系統)
点云投影图片
[unity3d] nested use layout group to make scroll view with dynamic sub object height
stm32和电机开发(上位系统)
[SUCTF2018]followme
Thanos Receiver
UVM——Callback
HDU1236 排名(结构体排序)
14. Code implementation of semaphore
[TS] 1368 seconds understand typescript generic tool types!
高考的意义是什么
JS settimeout() and interview questions
The nanny level tutorial of flutter environment configuration makes the doctor green to the end
使用Windbg静态分析dump文件(实战经验总结)
对话吴纲:我为什么笃信“大国品牌”的崛起?
传输优化抽象
使用sqlcipher打开加密的sqlite方法
LabVIEW为什么浮点数会丢失精度