当前位置:网站首页>10007. ISBN号码
10007. ISBN号码
2022-06-11 01:16:00 【DXB2021】
每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字、1位识别码和3位分隔符,其规定格式如“x-xxx-xxxxx-x”,其中符号“-”就是分隔符(键盘上的减号),最后一位是识别码,例如0-670-82162-4就是一个标准的ISBN码。ISBN码的首位数字表示书籍的出版语言,例如0代表英语;第一个分隔符“-”之后的三位数字代表出版社,例如670代表维京出版社;第二个分隔符后的五位数字代表该书在该出版社的编号;最后一位为识别码。
识别码的计算方法如下:
首位数字乘以1加上次位数字乘以2……以此类推,用所得的结果mod 11,所得的余数即为识别码,如果余数为10,则识别码为大写字母X。例如ISBN号码0-670-82162-4中的识别码4是这样得到的:对067082162这9个数字,从左至右,分别乘以1,2,...,9,再求和,即0×1+6×2+……+2×9=158,然后取158 mod 11的结果4作为识别码。
你的任务是编写程序判断输入的ISBN号码中识别码是否正确,如果正确,则仅输出“Right”;如果错误,则输出你认为是正确的ISBN号码。
输入格式:
只有一行,是一个字符序列,表示一本书的ISBN号码(保证输入符合ISBN号码的格式要求)。
输出格式:
只有一行,假如输入的ISBN号码的识别码正确,那么输出“Right”,否则,按照规定的格式,输出正确的ISBN号码(包括分隔符“-”)。
提示:
NOIP普及组2008
限制:
各个测试点1s
样例 1 :
输入: 0-670-82162-4
输出: Right
样例 2 :
输入: 0-670-82162-X
输出: 0-670-82162-4
C语言:
#include <stdio.h>
int main()
{
char isbn[13],right[13];
int temp1=1,sum=0;
scanf("%s",isbn);
for(int i=0;i<11;i++)
{
if(isbn[i]=='-')
continue;
if(isbn[i]>='0'&&isbn[i]<='9')
{
int temp2=isbn[i]-'0';
sum+=temp1*temp2;
temp1++;
}
}
if((sum%11)==isbn[13])
printf("Right");
else
{
for(int i=0;i<12;i++)
right[i]=isbn[i];
right[13]=sum%11;
printf("%s",right);
}
return 0;
}评测状态
答案错误 0
语言: C
用时: 0 ms 内存: 1088 kb 代码长度: 415
边栏推荐
- Test questions and answers of 2022r1 quick opening pressure vessel operation certificate
- 优化调度(火电、风能、储能)【matlab代码实现】
- Is it appropriate for a 27 - year-old girl to change her career from zero to software testing?
- Contest2902 - following Tang Kelian's programming: sequence structure question d: area 201502 question f: persistence of supporting college students in Ludian earthquake
- Shader of double sided material
- CRS-4544 & ORA-09925
- InfoQ 极客传媒 15 周年庆征文|容器运行时技术深度剖析
- [3.delphi common components] 7 timer
- aspects to consider for a recommendation letter
- 【并行与分布式系统】Cache学习
猜你喜欢

CRS-4544 & ORA-09925

CRS-4544 & ORA-09925

Tencent test development post interview programming questions

421. 数组中两个数的最大异或值

Introduction and practice of QT tcp/udp network protocol (I) TCP communication

ABAP CDS实现多行字段内容拼接

InfoQ 极客传媒 15 周年庆征文|容器运行时技术深度剖析

Task02: linked list

14: 00 interview, came out at 14:08, the question is really too

Binary tree sequence traversal
随机推荐
Rewrite: kms activates office2016, 2019 and 2021 with error code: 0xc004f069
Md61 plan independent demand import Bapi [by daily dimension / dynamic template / dynamic field]
Orcale driver
Oracle tablespaces, users, and authorization to users
Task07: double pointer
贵金属白银和现货白银之间是什么关系
Nodejs send mail
FB02编辑Coding Block字段
Knowledge competition of safety production month -- how much do you know about new safety law
Seven principles that should be known by software testers
[3.delphi common components] 6 scroll bar
[winning] Title A of the 9th Teddy Cup Challenge
[traffic sign recognition] Based on Matlab GUI YCbCr feature extraction +bp neural network traffic sign recognition [including Matlab source code 1869]
Find - (block find)
优化调度(火电、风能、储能)【matlab代码实现】
Question g: candy
Union find
English subtitle video translated into Chinese subtitles
Battery control of QT widget (qpainter)
JS summary of math functions in math objects