944,111 Members | Top Members by Rank

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

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2127
  • C++ RSS
Aug 11th, 2005
0

hi i have a question!!!!!! (^o^)

Expand Post »
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
Similar Threads
Reputation Points: 16
Solved Threads: 0
Light Poster
jasondrey13 is offline Offline
41 posts
since Jul 2005
Aug 11th, 2005
0

Re: hi i have a question!!!!!! (^o^)

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.
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
Aug 11th, 2005
0

Re: hi i have a question!!!!!! (^o^)

is there a way to name the value of variables like:

x += y += z == 12 AND (or whatever the operator is)
2 *= x -= 3 *= y = == 4 AND (or whatever the operator is)
y += z -= x == 2
Reputation Points: 16
Solved Threads: 0
Light Poster
jasondrey13 is offline Offline
41 posts
since Jul 2005
Aug 11th, 2005
0

Re: hi i have a question!!!!!! (^o^)

And what is "2 *= x -= 3 *= y = == 4" suppose to mean? This is completely nonsensical notation.
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
Aug 11th, 2005
0

Re: hi i have a question!!!!!! (^o^)

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".
Reputation Points: 22
Solved Threads: 5
Posting Whiz in Training
Drowzee is offline Offline
244 posts
since Jul 2005
Aug 11th, 2005
0

Re: hi i have a question!!!!!! (^o^)

haha ok i dont know a way to tell the computer in c++

set x AND y AND z using these equasions

is there a way to do that or am i asking the impossible and if there is can you please tell me thx
Reputation Points: 16
Solved Threads: 0
Light Poster
jasondrey13 is offline Offline
41 posts
since Jul 2005
Aug 11th, 2005
0

Re: hi i have a question!!!!!! (^o^)

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.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
Aug 13th, 2005
0

Re: hi i have a question!!!!!! (^o^)

thx ill try that
Reputation Points: 16
Solved Threads: 0
Light Poster
jasondrey13 is offline Offline
41 posts
since Jul 2005
Aug 13th, 2005
0

Re: hi i have a question!!!!!! (^o^)

To find values x, y, z for equations
C++ Syntax (Toggle Plain Text)
  1. ax + by + cz = r
  2. dx + ey + fz = s
  3. 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)
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
Aug 13th, 2005
0

Re: hi i have a question!!!!!! (^o^)

i got it thx
Reputation Points: 16
Solved Threads: 0
Light Poster
jasondrey13 is offline Offline
41 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: help me please....
Next Thread in C++ Forum Timeline: Passing a Function, function pointer





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC