当前位置:网站首页>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;
}
}
边栏推荐
猜你喜欢
随机推荐
js setTimeout()与面试题
In the face of uncertainty, the role of supply chain
stm32和電機開發(上比特系統)
正则及常用公式
Flink实时计算topN热榜
Thanos Receiver
01-spooldir
MySQL数据库远程访问权限设置
记录 AttributeError: ‘NoneType‘ object has no attribute ‘nextcall‘
[Fantasy 4] introduction and use of UMG components (under update...)
Set the playback speed during the playback of UOB equipment
Internet News: Tencent conference application market was officially launched; Soul went to Hong Kong to submit the listing application
Solutions to a series of problems in sqoop job creation
LabVIEW为什么浮点数会丢失精度
Leetcode+ 76 - 80 storm search topic
Flutter环境配置保姆级教程,让doctor一绿到底
LeetCode+ 76 - 80 暴搜专题
UVM - usage of common TLM port
AI技术产业热点分析
SPSS做Shapiro-Wilk正态分析

![[SUCTF2018]followme](/img/63/9104f9c8bd24937b0fc65053efec96.png)







![[Fantasy 4] the transformation from U3D to UE4](/img/bb/665eba3c8cd774c94fe14f169121da.png)