洛谷 P1055 [NOIP2008 普及组] ISBN 号码
更多...
#include <luogu.h>
|
static int | main (istream &cin, ostream &cout) |
|
洛谷 P1055 [NOIP2008 普及组] ISBN 号码
在文件 luogu.h 第 186 行定义.
◆ main()
int luogu::P1055::main |
( |
istream & | cin, |
|
|
ostream & | cout ) |
|
static |
在文件 luogu.cpp 第 483 行定义.
483 {
484 string isbn;
485 cin >> isbn;
486 const string isbn_prefix = isbn.substr(0, isbn.length() - 1);
487 int sum = 0;
488 int count = 1;
489 for(const char ch: isbn_prefix) {
490 if(isdigit(ch) != 0) {
491 sum += (ch - '0') * count++;
492 sum %= 11;
493 }
494 }
495 sum %= 11;
496 int end = *isbn.rbegin() - '0';
497 if(end == 'X' - '0') {
498 end = 10;
499 }
500 if(sum == end) {
501 cout << "Right";
502 } else {
503 end = sum;
504 if(sum == 10) {
505 end = 'X' - '0';
506 }
507 cout << isbn_prefix << static_cast<char>(end + '0');
508 }
509 return 0;
510 }
被这些函数引用 luogu::TEST() , 以及 luogu::TEST().
该类的文档由以下文件生成: