1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <iostream>
using namespace std;
unsigned int pack(int a, int b, int c, int d, int e, int f, int g, int h)
{
unsigned int abcdefgh;
abcdefgh = 10000000 * a + 1000000 * b + 100000 * c + 10000 * d + 1000 * e + 100 * f + 10 * g + h;
return abcdefgh;
}
int getDigit(unsigned int packthem, int choice) {
for (int i = 0; i<choice - 1; i++) {
packthem /= 10;
}
return packthem % 10;
}
int main() {
unsigned int final = 0;
int a, b, c, d, e, f, g, h;
int packthem;
int choice;
cout << "Enter a value: " << endl;
cin >> a;
cout << "Enter a value: " << endl;
cin >> b;
cout << "Enter a value: " << endl;
cin >> c;
cout << "Enter a value: " << endl;
cin >> d;
cout << "Enter a value: " << endl;
cin >> e;
cout << "Enter a value: " << endl;
cin >> f;
cout << "Enter a value: " << endl;
cin >> g;
cout << "Enter a value: " << endl;
cin >> h;
packthem = pack(a, b, c, d, e, f, g, h);
cout << packthem << endl;
cout << "Which numbers would you like to recover?" << endl;
cin >> choice;
final = getDigit(packthem, choice);
cout << final << endl;
cout << endl;
system("pause");
}
|