Nov 18, 2011 at 3:17am Nov 18, 2011 at 3:17am UTC
Ok, so i discovered c++ 4 days ago. IT took me a day to get the compiler, then that night I did the "hello world program", then I made a very simple code that finds the zeroes of a quadratic polynomial using the quadratic formula.
then I began writing a program that will divide polynomials of various degree's into one another, sounds simple but its not! Or not for me.
anyways my code works, but it is over 24 printed pages long, has a complex if(xx) structure of 50+ nested if's!
this is because it allows you to divide polynomials of various degree's, either ^3 or ^4 for the dividend and either ^1,^2,^3 for the divisor, and since i could not figure out a way to use the same code but have it work for all the varying degree's ( i tried, it would work in some cases but most it would try and divide by zero or just wouldn't work right)
is 24 pages way too long for a program like this? I've literally spent about 5 hours a day making this program, writing out long pages of separate algorithms for each different combination of degree in respect to both the divisor and dividend.
i would post my code but obviously i dont want to paste 24 pages worth of material
Nov 18, 2011 at 4:05am Nov 18, 2011 at 4:05am UTC
what are you trying to achieve exactly... give us a sample input and your expected output.
Thanks
Cheers
Nov 18, 2011 at 4:38am Nov 18, 2011 at 4:38am UTC
Well the thing is i have done exactly what I wanted to do, but it took 24 pages and a nested structure of over 50 if's within if's, I was wondering if this would be considered decent code? to me it seems like the only way to do what I'm trying to do
I made a program that divides polynomials of different degrees into one another
for example;
4x^4 + 12x^3 - 266 x^2 + 26x +3 / 2x^3 + x - 6 (4th degree divided by a 3rd degree)
or
3x^3 + 33x^2 - 16x + / 4x + 2 (3rd degree divided by 1st degree)
i think it is so complicated because i have to use a different set of code for each different combination of degree's of dividends and divisors.
so i have one whole 5 page long set of code for 4th degree / 1st degree, another 5 pages for a 4th degree/ 2nd degree, another 5 for 4th degree / 3rd degree, another set for 3rd degree divided by 1st degree etc.
it however works pretty well, idk how i could possibly pull out a snippet to give someone an idea of what my code is like, i'd have to post the whole thing
Nov 18, 2011 at 4:42am Nov 18, 2011 at 4:42am UTC
What's the expected output of your examples?
Jim
Nov 18, 2011 at 4:55am Nov 18, 2011 at 4:55am UTC
ok let me run it through my program
"4x^4 + 12x^3 - 266 x^2 + 26x +3 / 2x^3 + x - 6"
= 2x + 5 + ((-259x^2 + 54x -1)/ 2x^3 + x - 6
which is right, if you do it by hand you can check.
and 3x^3 + 33x^2 - 16x + / 4x + 2
= oops this one doesnt work because the first constant of the dividend is bigger than the first of the divisor. there are ways to get around this but it won't exactly do what i want it to do, which is to algebraically give me a reduced answer = to the original equation
the thing with polynomial division is it's not simple like regular long division, I had to make separate couple-page-long graphs and carefully log the relationships between the numbers under the dividend using a dual array ( 'line [x][x]'), and each one of these algorithms is different for the different degree of both divisor and dividend
i remind you i just learned the definition of "compiler" the other day (aka im a newb)
Nov 18, 2011 at 4:56am Nov 18, 2011 at 4:56am UTC
I second jim80y... also you might onto read up on loops and functions
Nov 18, 2011 at 4:59am Nov 18, 2011 at 4:59am UTC
how can you agree with his simple question?
and i have read up on loops but there are seriously so many different possibilities for answers that require slightly altered algorithms for each (i tried to make it simpler, but there would always be exceptions that would turn out plane wrong), for every possibility of a certain number being zero i had to create a seperate output so that i dont end up with a far off answer
Nov 18, 2011 at 5:25am Nov 18, 2011 at 5:25am UTC
it basically finds an equivelent equation that is more factored and easier to work with
if you have ever divided polynomials by hand you'll know what I'm talking about
anyways the whole code for just the 4th degree divided by 1st degree is too long for one post, so ill split it into two
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
if (secondchoice == 1)
{
cout << "you said your dividend is a 4rd degree polynomial, this will be in the form \n" ;
cout << " \n " ;
cout << " Ax^4 + Bx^3 + Cx^2 + Dx + E \n " ;
cout << "E is your constant term \n" ;
cout << " \n " ;
cout << "please enter in the corresponding coeffecients as they logically \n " << endl;
cout << "appear on screen. numbers must be whole intergers\n " << endl ;
cout << " \n " << endl;
cout << "please enter the proper coeffecients for the corresponding terms below \n" ;
cout << " \n " ;
cout <<" Ax^4 + Bx^3 + Cx^2 + Dx + E \n \n \n" ;
cout << " \n " ;
cout << "A term =" ; cin >> dive [0]; cout << dive [0] << endl;
cout << " \n " ;
cout << "B term =" ; cin >> dive [1]; cout << dive [1] << endl;
cout << " \n " ;
cout << "C term =" ; cin >> dive [2]; cout << dive [2] << endl;
cout << " \n " ;
cout << "D term =" ; cin >> dive [3]; cout << dive [3] << endl;
cout << " \n " ;
cout << "E term(constant) =" ; cin >> dive [4]; cout << dive [4] << endl;
cout << "your polynomial is \n" ;
cout << " \n " ;
cout << " " << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3] << "x + " << dive [4] << endl;
cout << "is this correct (0 for NO, anything else for YES)" << endl;// to make sure input is correct
cin >> check_input1;
cout << " \n \n \n \n \n \n \n " << endl;
if (check_input1 == 0)
{
cout << "re-enter your A,B,C, D, and E terms, one by one. hitting enter after each one \n" << endl;
cin >> dive [0];
cin >> dive [1];
cin >> dive [2];
cin >> dive [3];
cin >> dive [4];
cout << "your dividend polynomial is \n" ;
cout << " " << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3] << "x + " << dive [4] << endl;
cout << " \n \n \n \n \n \n \n " << endl;
check_input1 = 2;/* makes it so whatever they enter in the second time gets automatically passed onto the divisor
input*/
}
if (check_input1 != 0)
{
cout << "you have stated that your divisor is a 1st degree polynomial /n" << endl;
cout << "this will be in the form \n" << endl;
cout << "Ax + B \n" << endl;
cout << "\n" ;
cout << "please enter your A term" ; cin >> divi [0]; cout << divi [0] << endl;
cout << "please enter your b term" ; cin >> divi [1]; cout << divi [1] << endl;
cout << "your divisor polynomial is \n" ;
cout << divi [0] << "x + " << divi [1] << endl;
cout << "is this correct (0 for NO anything else for YES) \n \n \n \n \n \n \n" << endl;// to make sure input is correct
cin >> check_input2;
if (check_input2 == 0)
{
cout << "re-enter your A, and B term, one by one. hitting enter after each one \n" << endl;
cin >> divi [0];
cin >> divi [1];
cout << "your divisor polynomial is \n \n \n \n \n \n" ;
cout << divi [0] << "x^2 + " << divi [1] << endl;
}
else
{
quo [0] = dive [0] / divi [0];
line [0][0] = quo [0] * divi [0];
line [0][1] = quo [0] * divi [1];
line [1][0] = dive [0] - line [0][0];
line [1][1] = dive [1] - line [0][1];
line [1][2] = dive [2];
line [1][3] = dive [3];
line [1][4] = dive [4];
if (line [1][0] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3" << " + (" << line [1][0] << "x^4" << " + " << line [1][1] << "x^3 + " <<
line [1][2] << "x^2 + " << line [1][3] << "x + " << line [1][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (line [1][0] == 0)
{
if (line [1][1] == 0)
{
if (divi [0] > abs(line [1][2]))
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3" << " + (" << line [1][2] << "x^2 + " << line [1][3] << "x + " << line [1][4] << ") / "
<< divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (divi [0] <= abs( line [1][2]))
{
quo [1] = line [1][2] / divi [0];
line [2][2] = quo [1] * divi [0];
line [2][3] = quo [1] * divi [1];
line [2][4] = dive [4];
line [3][2] = line [1][2] - line [2][2];
line [3][3] = line [1][3] - line [2][3];
line [3][4] = line [2][4];
if (line [3][2] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x " << " + (" <<
line [3][2] << "x^2 + " << line [3][3] << "x + " << line [3][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (line [3][2] == 0)
{
if (line [3][3] == 0)
{
if (line [3][4] != 0)
{ cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x " <<
" + (" << line [3][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (line [3][4] == 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x " << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
}
if (divi [0] > abs(line [3][3]))
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x " << " + (" << line [3][3] << "x + " << line [3][4] << ") / "
<< divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (divi [0] <= abs(line [3][3]))
{
quo [2] = line [3][3] / divi [0];
line [4][3] = quo [2] * divi [0];
line [4][4] = quo [2] * divi [1];
line [5][3] = line [3][3] - line [4][3];
line [5][4] = line [3][4] - line [4][4];
if (line [5][3] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x + " << quo [2] << " + ("
<< line [5][3] << "x + " << line [5][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
Last edited on Nov 18, 2011 at 5:43am Nov 18, 2011 at 5:43am UTC
Nov 18, 2011 at 5:25am Nov 18, 2011 at 5:25am UTC
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
if (line [5][3] == 0)
{
if (line [5][4] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x + " << quo [2] << " + ("
<< line [5][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (line [5][4] == 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x + " << quo [2] <<
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
}
}// close for if line [3][2] == 0
}//end for 10&11 = 0 and i0 can divide into 12
}// close for if line [1][1] = 0)
}
if (line [1][1] != 0)
{
if (divi [0] > abs (line [1][1]))
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " " + ("
<< line [1][1] << "x^3 + " << line [1][2] << "x^2 + " << line [1][3] << "x + " << line [1][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (divi [0] <= line [1][1])
{
quo [1] = line [1][1] / divi [0];
line [2][1] = quo [1] * divi [0];
line [2][2] = quo [1] * divi [1];
line [3][1] = line [1][1] - line [2][1];
line [3][2] = line [1][2] - line [2][2];
line [3][3] = line [1][3];
line [3][4] = line [1][4];
if (line [3][1] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 " " + ("
<< line [3][1] << "x^3 + " << line [3][2] << "x^2 + " << line [3][3] << "x + " << line [3][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (line [3][1] == 0)
{
if (line [3][2] == 0)
{
if (divi [0] > abs (line [3][3]))
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 " " + ("
<< line [3][3] << "x + " << line [3][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (divi [0] <= abs ( line [3][3]))
{
quo [2] = line [3][3] / divi [0];
line [4][3] = quo [2] * divi [0];
line [4][4] = quo [2] * divi [1];
line [5][3] = line [3][3] - line [4][3];
line [5][4] = line [3][4] - line [4][4];
if (line [5][3] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << " + ("
<< line [5][3] << "x + " << line [5][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}//close for if line 53 != 0
if (line [5][3] == 0 && line [5][4] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << " + ("
<< line [5][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (line [5][3] ==0 && line [5][4] == 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] <<
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
}
}//close for if line [3][2] == 0
if (line [3][2] != 0)
{
if (divi [0] > abs (line [3][2]))
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 " << " + ("
<< line [3][2] << "x^2 + " << line [3][3] << "x + " << line [5][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
Last edited on Nov 18, 2011 at 5:43am Nov 18, 2011 at 5:43am UTC
Nov 18, 2011 at 5:25am Nov 18, 2011 at 5:25am UTC
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
if (divi [0] <= abs (line [3][2]))
{
quo [2] = line [3][2] / divi [0];
line [4][2] = quo [2] * divi [0];
line [4][3] = quo [2] * divi [1];
line [4][4] = line [3][4];
line [5][2] = line [3][2] - line [4][2];
line [5][3] = line [3][3] - line [4][3];
line [5][4] = line [4][4];
if (line [5][2] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << "x + ("
<< line [5][2] << "x^2 + " << line [5][3] << "x + " << line [5][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (line [5][2] == 0)
{
if ( line [5][3] == 0 && line [5][4] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << "x + ("
<< line [5][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (line [5][3] == 0 && line [5][4] == 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << "x" << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (divi [0] > abs( line [5][3]))
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << "x + ("
<< line [5][3] << "x + " << line [5][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
if (divi [0] <= abs( line [5][3]))
{
quo [3] = line [5][3] / divi [0];
line [6][3] = quo [3] * divi [0];
line [6][4] = quo [3] * divi [1];
line [7][3] = line [5][3] - line [6][3];
line [7][4] = line [5][4] - line [6][4];
if (line [7][3] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << "x + " << quo [3] << " + ("
<< line [7][3] << "x + " << line [7][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}// close for if 73 != 0
if (line [7][3] == 0)
{
if (line [7][4] != 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << "x + " << quo [3] << " + ("
<< line [7][4] << ") / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}// for if 74 != 0
if (line [7][4] == 0)
{
cout << dive [0] << "x^4 + " << dive [1] << "x^3 + " << dive [2] << "x^2 + " << dive [3]
<< "x +" << dive [4] << " / " << divi [0] << "x + " << divi [1] << endl;
cout << " \n = " << quo [0] << "x^3 + " << quo [1] << "x^2 +" << quo [2] << "x + " << quo [3] <<
cout << " \n \n \n \n \n \n " << endl;
system("PAUSE" );
return main();
}
}
}//close for if [7][3] == 0
}//close for is divi can go into line 53
}//close for if line 52 == 0)
}// close for in line 52 != 0
}// close for if line [3][2] can be divided by our divi 0
}// close for if line [3][2] != 0
}//close for if line 31 ==0 after line 11 didnt == 0)
}
}// close for if line [1][1] != 0)
} // close for line[1][0] = 0
}// close for divisor = 1st degree
Last edited on Nov 18, 2011 at 5:43am Nov 18, 2011 at 5:43am UTC
Nov 18, 2011 at 6:54am Nov 18, 2011 at 6:54am UTC
ok so i compiled a huge page of different problems testing every different combination of degree's of dividends and divisors and every one came out correct, so it works.
:]