I have a problem adding the units, tens and hundreds of a vector. Showing it in an example:
vector [0] = 123 vector 1 = 456 vector [2] = 78
And that in units there are 17, in tens 14 and in hundreds 5. Adding in vertical line.
for (int i = 0; i < vector.GetLength(0); i++)
{
if (vector[i] < 10)
{
u = u + vector[i];
}
if (vector[i] < 100)
{
valor = Convert.ToString(vector[i]);
d = d + Convert.ToInt32(valor[0]);
u = u + Convert.ToInt32(valor[1]);
}
else
{
valor = Convert.ToString(vector[i]);
c = c + Convert.ToInt32(valor[0]);
d = d + Convert.ToInt32(valor[1]);
u = u + Convert.ToInt32(valor[2]);
}
But I have this problem, I get big numbers, where is the anomaly?