Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <string>
- #include "ISBNPrefix.h"
- #include "ISBN.h"
- using namespace std;
- int isValid(const char str[]){
- int length=0, run=0, a, b, checkint=0, hold, total=0;
- string check;
- cout << str << endl;
- length=strlen(str);
- cout << length << endl;
- if(length==10)
- run=0;
- if(run==0){
- check=str;
- if(str[9]=='x'){
- b=10;
- cout << "check with x: " << check << endl;
- for(a=8;a>=0;a--){
- hold = (int)check[a];
- hold = hold * b;
- total = total + hold;
- b--;
- }
- total = total + 10;
- if(total%11!=0)
- run=1;
- }
- else{
- b=10;
- checkint = atoi (check.c_str());
- cout << "At x: " << check << endl;
- for(a=0;a<=8;a++){
- hold = (check[a] - '0');
- cout << "THIS IS HOLD" << hold << endl;
- hold = (hold*b);
- cout << "THIS IS HOLD AFTER MULTIPLYING" << hold << endl;
- total = total + hold;
- cout << "THIS IS TOTAL" << total << endl;
- b--;
- }
- total = total + (check[a]-'0');
- cout << "THIS IS TOTAL" << total << endl;
- if(total%11!=0)
- run=1;
- }
- }
- cout << "THIS IS RUN AT THE END: " << run << endl;
- if(run!=0)
- return 0;
- else
- return 1;
- }
- int isRegistered(FILE* fp, const char str[], char area[], char publisher[], char title[]){
- int intarea, finished=0, a, length=1, check=1, valid, titlelength, areavalid, publishervalid, truth=1;
- char compare[80], hold[80], holdtwo[80];
- cout << "IN ISREGISTERED" << endl;
- valid=isValid(str);
- cout << "THIS IS VALID" << endl;
- if(valid==1){
- cout << "INSIDE VALID" << endl;
- while(finished==0){
- cout << "IN WHILE IN REGISTERED" << endl;
- for(a=0;a<length;a++)
- compare[a]=str[a];
- compare[a+1]='\0';
- cout << "THIS IS COMPARE: " << compare << endl;
- intarea = atoi (compare);
- cout << "THIS IS INTAREA: " << intarea << endl;
- truth=registeredArea(fp, intarea);
- if(truth==0){
- finished=1;
- area=compare;
- areavalid=0;
- }
- else if(truth==1){
- areavalid=1;
- if(length < 6)
- length++;
- else if(length > 5)
- finished=1;
- }
- }
- finished=0;
- truth=0;
- while(finished==0){
- if(check < 10)
- cout << "IN SECOND WHILE" << endl;
- for(a=0;a<check;a++)
- holdtwo[a]=str[a+length];
- holdtwo[check]='\0';
- for(a=0;a<2;a++)
- cout << holdtwo[a] << endl;
- truth=registeredAP(fp, intarea, holdtwo);
- if(truth==0){
- finished=1;
- publisher=holdtwo;
- publishervalid=0;
- }
- else if(truth==1)
- publishervalid=1;
- check++;
- }
- length=check+length;
- titlelength=(9-length);
- for(a=0;a<titlelength;a++)
- title[a]=str[length];
- }
- if(areavalid==0 && publishervalid==0)
- return 0;
- else
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment