Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- int getIsbnChecksum( string );// Prototype for this function.
- int getIsbnChecksum( string isbnBase ) {
- int sum = 0;
- for ( int i = 0; i < 12; i++ ) {
- if ( i % 3 != 0 )
- sum += int( isbnBase[ i ] - '0' );
- else
- sum += int( isbnBase[ i ] - '0' ) * 3;
- }
- int checksum = ( 10 - sum % 10 ) % 10;
- return checksum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement