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
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector <int> Char_Weight { 6, 18, 24, 66, 35, 54, 63, 72, 81, 90, 99, 108, 117, 126, \
135, 144, 153, 162, 171, 180, 189, 798, 807, 116, 325, 934 };
int main (void) {
string Nme;
int Value;
cout << "Name: ";
cin >> Nme;
if ( !Nme.empty () ) {
Value = 0;
for ( auto ch : Nme ) {
int Weight = int ( toupper (ch) - 'A');
Value += Char_Weight [Weight];
}
cout << " Weight value = " << Value;
}
return 0;
}
|