Error during matrix processing
May 15, 2017 at 6:46pm UTC
I have a Function class that contains the union, difference, assignment, and intersection operators (+, -, =, *).
The problem is that I can not output the resulting set (F). Output only F = {}
I think that the error in the cycle of processing vectors by the matrix.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
//Creating objects
Function *obj,result,result1,obj1,obj2;
//size- Number of objects
int size = Convert::ToInt64(textBox2->Text);
//number - Auxiliary variable
String^ number;
//Creating an array of objects
obj = new Function[size];
int i = 0;
int n;
//Reading numbers from textBox4
for (int j = 0; j < size; j++, i++)
{
obj[j].input2(Convert::ToInt64(textBox3->Text));
while (textBox4->Text[i] != '\n' )
{
if (isdigit(textBox4->Text[i]) != 0)
{
if (textBox4->Text[i + 1] == ' ' )
{
number = Convert::ToString(textBox4->Text[i]);
n = Convert::ToInt64(number);
obj[j].input(n);
number = "" ;
}
else
{
int count = 0;
while (textBox4->Text[i + 1] != ' ' && textBox4->Text[i + 1] != '\n' )
{
count++;
i++;
}
i -= count;
count++;
while (count != 0)
{
count--;
number = number + textBox4->Text[i];
i++;
}
i--;
n = Convert::ToInt64(number);
obj[j].input(n);
number = "" ;
}
}
i++;
}
}
//Matrix processing of vectors
for (int i = 0; i < k; i++)
for (int j = 0; j < size; j++)
{
if (matr[i][j] == '0' )
{
obj2 = obj[j];
obj1 = obj1 * (-obj2);
}
else if (matr[i][j] == '1' )
{
obj1 = obj1 * obj[j];
}
result = result + obj1;
}
//Vector output
textBox4->Text += Environment::NewLine;
textBox4->Text += "F={" ;
for (int o = 0; o < result.getsize();o++)
textBox4->Text += Convert::ToString(result.output(o))+" " ;
textBox4->Text += "}" ;
}
May 17, 2017 at 8:18am UTC
I'm afraid if you don't provide a minimum compilable example you are not likely to get any answer...
Topic archived. No new replies allowed.