I wish to know, how I can use each of the digits of a 15 digit code supplied by a user to compute a formula like this:
Given that the 15 digit code is represented as ABCDEFGHIJKLMNO
A*3+B*7+C*3+D*3+E*7F*3+G*3+H*7+I*3+J*3+K*7+L*3+M*3+N*7+O*3
How do i find the result of this computation using an array to represent the 15 digit code in which user will input sigle digits from A to O.
@CollinsLainzo, please delete your duplicate posts. Just keep this one.
@Ganado, I think the letters just represent the single decimal digits of a 15 digit number. The 3's and 7's are part of the formula. So if the number was 123456789012345 the calculation would be 1*3 + 2*7 + 3*3 + ...
Sorry the letters actually represent a 15 digit code which will be supplied by the user at tun time. Once the user inputs the 15 digit code, each number of the code should represent the corresponding alphabet (A, B, C etc) and computation should take place to determine the final value. the 3s and 7s are constants to be use for multiplication of the digits of the code
Can I get a solution which with little complexity but good effficiency.
the idea / pseudocode
int table[] = {3,7}; //used an array. but professors get irritated when you do stuff logically...
for(x=...)
{
cin >> input;
result += input*table[x%3==0] //adjust this for your pattern or adjust x in loop
}
note its a pattern of 3,3,7 repeating, and you happen to start at an offset.