小编Ben*_*zel的帖子

C++计算总是打印出11

我目前正在编写一个程序,根据用户输入的ISBN的一部分提供校验和.我对13位ISBN的计算给了我正确的答案,但由于某种原因,无论我输入什么,10位数的计算总是给我11.

cout << "Enter the digits one at a time, as if they were to be read from right to left." << endl;

cin >> digit_one;
cin >> digit_two;
cin >> digit_three;
cin >> digit_four;
cin >> digit_five;
cin >> digit_six;
cin >> digit_seven;
cin >> digit_eight;
cin >> digit_nine;

checksum = (11 - (((10, 9, 8, 7, 6, 5, 4, 3, 2) * (digit_one, digit_two, digit_three, digit_four, digit_five, digit_six, digit_seven, digit_eight, digit_nine)) % 11));

cout << "The checksum for …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
101
查看次数

标签 统计

c++ ×1