- #1
jellofaceman
- 12
- 0
1.Before I start it is important to say that I only have two months programming experience so my capabilities are limited. I have been working on a C# code to solve general case verbal arithmetic problems, but I ran into some trouble with one part of the algorithm. If you are not familiar with verbal arithmetic, here's some details: http://en.wikipedia.org/wiki/Verbal_arithmetic.
Part of the solution process (for me, anyway) involves using for loops to change the values in an array. I then use those values to calculate the value of each word. For example, I set up an array with the corresponding values M=1, O=0, R=8, E=5 and calculate (using another function) MORE=1085. I want to generate and test each value from 0-9 for each letter combined together (code 1B below gives a better idea of what I mean).
Unfortunately, I'm not having any success using for loops. When I define the array by itself (see 1a. below for example) I have no trouble reading the values. When I use a for loop(1b below), however, the program fails to give any results besides 0+0=0.
Anyway, any suggestions or pointers for how I could approach the code differently? Also, help with my lack of experience in mind would be appreciated. I'm not familiar with much more than loops, some basic pointers, operators, and functions.:
Part of the solution process (for me, anyway) involves using for loops to change the values in an array. I then use those values to calculate the value of each word. For example, I set up an array with the corresponding values M=1, O=0, R=8, E=5 and calculate (using another function) MORE=1085. I want to generate and test each value from 0-9 for each letter combined together (code 1B below gives a better idea of what I mean).
Unfortunately, I'm not having any success using for loops. When I define the array by itself (see 1a. below for example) I have no trouble reading the values. When I use a for loop(1b below), however, the program fails to give any results besides 0+0=0.
Anyway, any suggestions or pointers for how I could approach the code differently? Also, help with my lack of experience in mind would be appreciated. I'm not familiar with much more than loops, some basic pointers, operators, and functions.:
Code:
1A.
...
va[0]=1;
va[1]=2;
va[2]=3;
etc...
Code:
1B.
...
for(va[9]=0; va[9]<10; va[9]++)
{
for(va[8]=0; va[8]<10; va[8]++)
{
for(va[7]=0; va[7]<10; va[7]++)
{
for(va[6]=0; va[6]<10; va[6]++)
{
for(va[5]=0; va[5]<10; va[5]++)
{
for(va[4]=0; va[4]<10; va[4]++)
{
for(va[3]=0; va[3]<10; va[3]++)
{
for(va[2]=0; va[2]<10; va[2]++)
{
for(va[1]=0; va[1]<10; va[1]++)
{
for(va[0]=0; va[0]<10; va[0]++)
//Below this: For loops that give words values
Last edited: