subject

Can you help me solve the following for C programming?

LAB: Brute force equation solver
Numerous engineering and scientific applications require finding solutions to a set of equations. Ex: 8x + 7y = 38 and 3x - 5y = -1 have a solution x = 3, y = 2. Given integer coefficients of two linear equations with variables x and y, use brute force to find an integer solution for x and y in the range -10 to 10.

Ex: If the input is:

8 7 38
3 -5 -1
then the output is:

3 2
Use this brute force approach:

For every value of x from -10 to 10
For every value of y from -10 to 10
Check if the current x and y satisfy both equations. If so, output the solution, and finish.
Ex: If no solution is found, output:

No solution
You can assume the two equations have no more than one solution.

Note: Elegant mathematical techniques exist to solve such linear equations. However, for other kinds of equations or situations, brute force can be handy.

I'm having trouble finding a brute force solution. This is what I have so far. Thanks!

#include

int main(void) {
//variables with input will be coefficients of x and y for equation 1, and the solution for equation 1,
// and coefficients of x and y for equation 2, and the solution for equation 2
//variables that depend on input will be x and y in the range of -10 to 10

int coeffX1;
int coeffY1;
int solut1;
int coeffX2;
int coeffY2;
int solut2;
int X;
int Y;

//code should Check if the current x and y satisfy both equations. If so, output the solution, and finish.
//For every value of x from -10 to 10 && For every value of y from -10 to 10
scanf("%d %d %d %d %d %d",&coeffX1,&coeffY1,& solut1,&coeffX2,&coeffY2,&a mp;solut2);
X=-10;
Y=-10;
while(X>=-10 && X<=10){
if(!=X, X=solut2){
X=X+1;
}
while( Y>=-10 && Y<=10){
if((X*coeffX1)+(Y*coeffY1)!=solut1 &&(X*coeffX2)+(Y*coeffY2)!= solut2){

Y=Y+1;
}
if((X*coeffX1)+(Y*coeffY1)==solut1 &&(X*coeffX2)+(Y*coeffY2)== solut2)
{
printf("%d %d",X, Y);
}
}

}

//printf("%d %d %d \n%d %d %d",coeffX1,coeffY1,solut1,coeffX2, coeffY2,solut2);
//X=((coeffY2*Y+solut2)/coeffX2); //solut1=coeffX1*((coeffY2*Y+solut2 )/coeffX2)+(coeffY2*Y);
//printf("%d",Y);

return 0;
}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 22:40, azariah7
22. sata3 allows for data transfer rates of 600 mb/s. explain why you would likely not be able to copy data from one hard drive to another at anywhere close to this speed. also, what could be upgraded on the computer to achieve transfer speeds closer to 600 mb/s
Answers: 1
image
Computers and Technology, 24.06.2019 06:30, meganwintergirl
Ineed to know the anwser to all these questions
Answers: 2
image
Computers and Technology, 24.06.2019 15:30, taylorpayne525p8qxky
What is not a type of text format that will automatically be converted by outlook into a hyperlink?
Answers: 1
image
Computers and Technology, 24.06.2019 19:00, stephanieanaya7
In python a floating-point number must be written using scientific notation?
Answers: 1
You know the right answer?
Can you help me solve the following for C programming?

LAB: Brute force equation solver<...

Questions in other subjects:

Konu
English, 26.07.2019 03:40