| | |
hi i have a question!!!!!! (^o^)
Please support our C++ advertiser: Intel Parallel Studio Home
| View Poll Results: do you need this post | |||
| ya | | 1 | 25.00% |
| i guess | | 0 | 0% |
| no | | 3 | 75.00% |
| Voters: 4. You may not vote on this poll | |||
![]() |
hi i need to make a homework helper for 3 equasions 3 unknowns
that will ask me what the equasions are and calculate what the unknowns are i thoght i would ask what the first char was a number or a letter and if it was a number it would store it in an int if it was a letter it would store it on a string...............
is there an and thing so i could tell the computer like
x += y += z == 12 AND
2 *= x -= 3 *= y = == 4 AND
y += z -= x == 2
cout<<"x="<<x<<;
cout<<"y="<<y<<;
cout<<"z="<<z<<;
thx,
Jason
that will ask me what the equasions are and calculate what the unknowns are i thoght i would ask what the first char was a number or a letter and if it was a number it would store it in an int if it was a letter it would store it on a string...............
is there an and thing so i could tell the computer like
x += y += z == 12 AND
2 *= x -= 3 *= y = == 4 AND
y += z -= x == 2
cout<<"x="<<x<<;
cout<<"y="<<y<<;
cout<<"z="<<z<<;
thx,
Jason
Of the syntax you used to state the problem and the syntax in your sample input, I'm not sure which makes the least sense.
You could be helpful and explain your problem better. Using sentences. Right now, I'm thinking that _maybe_ you're trying to solve a three-by-three linear system. And "2 *= x -= 3 *= y = == 4" makes no sense whatsoever.
You could be helpful and explain your problem better. Using sentences. Right now, I'm thinking that _maybe_ you're trying to solve a three-by-three linear system. And "2 *= x -= 3 *= y = == 4" makes no sense whatsoever.
•
•
Join Date: Jul 2005
Posts: 244
Reputation:
Solved Threads: 5
Looks like it's trying to be linear algebra.
But just to be sure:
Jasondrey13, is this what you want to solve?
x +y + z = 12;
(2 * x) - (3 * y) = 4
y + z - x = 2
Currently, you're trying to put things into code that aren't correct. The conversion from regular equations to C-style equations is not "Add an equal sign after every operation symbol".
But just to be sure:
Jasondrey13, is this what you want to solve?
x +y + z = 12;
(2 * x) - (3 * y) = 4
y + z - x = 2
Currently, you're trying to put things into code that aren't correct. The conversion from regular equations to C-style equations is not "Add an equal sign after every operation symbol".
•
•
Join Date: Jul 2005
Posts: 1,699
Reputation:
Solved Threads: 273
It's not impossible to solve the system of three equations with three unknowns using C/C++ but it isn't trivial either. The options to do it using a computer running a program written in C/C++ would be essentially the same as if you were doing it by hand, with the syntax adjusted as appropriate for the computer language as opposed to the mathematical language. Is there a standard function/library you could use to do this? I doubt it very much. Could you write your own? Sure, but it's going to require a lot of work. Could you scour the internet and find a third party library to do it for you? Quite possibly. I'm sure somebody has converted the pen and paper process into C/C++, but whether you'll be able to find a version of that program/algorithm on the internet is open to speculation, and it's not likely someone here is going to write this type of program for you.
No matter how you do it, at some point you will likely need some mechanism to separate the variable coefficients from the variables per se'. Depending on your restaints, you could ask the user to input this data for you or you could accept the equations as strings and parse out the various system variables, coefficients, and constants.
Once you have the vrarious coefficients, variables, and constants isolated, you probably already know that you can solve this type of system of equations using
1) linear algebra and matrixes or
2) isolate x in terms of y and z using equation 1, then y in terms of z in equation 2, and finally solve for z using equation 3 and the appropriate substitutions or
3) some other technique.
Once you've devised ways to isolate the information needed and determined the algorithm you are going to use, then you can start thinking about how to write the code.
No matter how you do it, at some point you will likely need some mechanism to separate the variable coefficients from the variables per se'. Depending on your restaints, you could ask the user to input this data for you or you could accept the equations as strings and parse out the various system variables, coefficients, and constants.
Once you have the vrarious coefficients, variables, and constants isolated, you probably already know that you can solve this type of system of equations using
1) linear algebra and matrixes or
2) isolate x in terms of y and z using equation 1, then y in terms of z in equation 2, and finally solve for z using equation 3 and the appropriate substitutions or
3) some other technique.
Once you've devised ways to isolate the information needed and determined the algorithm you are going to use, then you can start thinking about how to write the code.
To find values x, y, z for equations
You could use the formulas
x = (e*i - f*h) * r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (b*i - c*h) * s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) + (b*f - c*e)*t/(g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
y = -(-g*f + d*i)*r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) + (-g*c + a*i)*s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (-d*c + a*f)*t / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
z = (-g*e + d*h)*r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (-g*b + a*h)*s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)+( - d*b + a*e)*t / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
C++ Syntax (Toggle Plain Text)
ax + by + cz = r dx + ey + fz = s gx + hy + iz = t
You could use the formulas
x = (e*i - f*h) * r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (b*i - c*h) * s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) + (b*f - c*e)*t/(g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
y = -(-g*f + d*i)*r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) + (-g*c + a*i)*s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (-d*c + a*f)*t / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
z = (-g*e + d*h)*r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (-g*b + a*h)*s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)+( - d*b + a*e)*t / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
![]() |
Similar Threads
- C command-line I/O question (C++)
- Apache Alias Directive... mod_alias question (Linux Servers and Apache)
- Completely new to C++ and have question about using char (C++)
- Question (Geeks' Lounge)
- question on cooling (Cases, Fans and Power Supplies)
- Context-sensitive grammar question :( (Computer Science)
- Welcome PC Mod Kingdom peeps! (Geeks' Lounge)
- Laptop LCD built into a car? (Monitors, Displays and Video Cards)
- Changing Network Configuration (*nix Software)
Other Threads in the C++ Forum
- Previous Thread: help me please....
- Next Thread: Passing a Function, function pointer
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelp homeworkhelper iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings template text tree url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






