vector Modification Modify the National Commerce Bank case s
vector Modification
Modify the National Commerce Bank case study presented in Program 7-23 so pin1 ,
pin2 , and pin3 are vector s instead of arrays. You must also modify the testPIN
function to accept a vector instead of an array.
Solution
#include <iostream>
#include<vector>
using namespace std;
// Function Prototype
bool testPIN(int [], int [], int);
int main ()
{
const int NUM_DIGITS = 7; // Number of digits in a PIN
int cpin1[NUM_DIGITS] = {2, 4, 1, 8, 7, 9, 0}; // Base set of values.
int cpin2[NUM_DIGITS] = {2, 4, 6, 8, 7, 9, 0};
int cpin3[NUM_DIGITS] = {1, 2, 3, 4, 5, 6, 7};
vector<int> pin1(cpin1, cpin1+7) ;
vector<int> pin2(cpin2, cpin2+7) ;
vector<int> pin3(cpin3, cpin3+7) ;
if (testPIN(pin1, pin2, NUM_DIGITS))
cout << \"ERROR: pin1 and pin2 report to be the same.\ \";
else
cout << \"SUCCESS: pin1 and pin2 are different.\ \";
if (testPIN(pin1, pin3, NUM_DIGITS))
cout << \"ERROR: pin1 and pin3 report to be the same.\ \";
else
cout << \"SUCCESS: pin1 and pin3 are different.\ \";
if (testPIN(pin1, pin1, NUM_DIGITS))
cout << \"SUCCESS: pin1 and pin1 report to be the same.\ \";
else
cout << \"ERROR: pin1 and pin1 report to be different.\ \";
return 0;
}
bool testPIN(int custPIN[], int databasePIN[], int size)
{................}
