FAQSearchMembersGroupsRegisterProfilePM'sLogin/Logout

Warcraft Occult Forum Index -> Feedback

Dont Look

  Author    Thread Post new topic Reply to topic
Guest





Dont Look

/*

Program Information:
Bob goes into 7-11 and buys 4 items. He checks it out and the clerk says,
"that'll be item 1 * item 2 * item 3 * item 4..coming out to 7.11."
Bob says "I just want to add them together to get my total".
The clerk says "It's the same either way."

Write a program to determine what these 4 amounts are in the most efficient way possible.

If you can do that, alter the program to replace 7.11 with a number that the user
types in.

Lastly, if you can finish that, also have the user type in the amount of items.

If the items CANNOT add/multiplyh to the total, then tell the user.

*/

#include<iostream>

using namespace std;

int main()
{

int Va = 1;
int Vb = 1;
int Vc = 1;
int Vd = 1;
int Vtestcounter = 1;
int Vtotal = 711;
long Vmult = 71100000;

for (Va = Vb; Va < Vtotal; Va++) //Increment 'Va', until it equals Vtotal starting at 'Vb' See Note 1
{

for (Vb = Vc; Vb < Vtotal; Vb++) //Increment 'Vb' until it equals Vtotal, starting at 'Vc'
{

for (Vc = Vd; Vc < Vtotal; Vc++) //Increment 'Vb' until it equals Vtotal, starting at 'Vc'
{

for (Vd = 1; Vd < Vtotal; Vd++)
{
cout << "Sum: " << Va + Vb + Vc +Vd << " Product: " << Va * Vb * Vc * Vd << " " << Va << " " << Vb << " " << Vc << " " << Vd << " " << Vtestcounter << endl; //Helps keep track of output

if ((Va + Vb + Vc + Vd == Vtotal) && (Va * Vb * Vc * Vd == Vmult)) //If When added they come to the correct value, and when multiplied they do as well..
{
cout << "WE HAVE AN ANSWER!! " << endl << endl << "THE ANSWER IS: " << Va << " " << Vb << " " << Vc << " " << Vd << " " << endl; //If you find the answer, it will let you know.

Va = Vb = Vc = Vd = Vtotal+1; //Makes all the values 1 greater than Vtotal so that you can exit all of the 'For' loops
}


//If incorrect..
else
{
Vtestcounter = Vd; //Start testcounter at 0

while (Vmult % Vtestcounter != 0) //While Vmult / Vmult does not come out evenly
Vtestcounter++; //Increment Vtestcounter so that it comes out evenly

Vd = Vtestcounter; //Make 'Vd' equal to Vtestcounter
} //End "else"


//Now it is going to increment Vd until it reaches the highest number that can go into Vtotal

} //End Vd For Loop
Vtestcounter = Vc; //Vtestcounter is now saved as 'Vc', which will at first equal 1, then increment each time 'Vd' goes through to the highest integar

while (Vmult % Vtestcounter != 0) //While Vmult / Vtestcounter does not come out evenly
Vtestcounter++; //Increment Vtestcounter so that it comes out evenly

Vc = Vtestcounter; //Make 'Vc' equal to Vtestcounter
Vd = 1; //Reset the value of 'Vd', so that it can be used for next loop.
} //End Vc For Loop

Vtestcounter = Vb; //Vtestcounter is now saved as 'Vb', which will at first equal 1, then increment each time 'Vd' goes through to the highest integar

while (Vtotal % Vtestcounter != 0) //While Vmult / Vtestcounter does not come out evenly
Vtestcounter++; //Increment Vtestcounter so that it comes out evenly

Vb = Vtestcounter; //Make 'Vd' equal to Vtestcounter
Vd = Vc = 1; //Reset 'Vd' and 'Vc'

} //End 'Vb' For Loop

Vtestcounter = Va; //Vtestcounter is now saved as 'Va', which will at first equal 1, then increment each time 'Vd' goes through to the highest integar

while (Vmult % Vtestcounter != 0) //While Vmult / Vtestcounter does not come out evenly
Vtestcounter++; //Increment Vtestcounter so that it comes out evenly

Va = Vtestcounter; //Make 'Va' equal to Vtestcounter
Vb = Vc = Vd = 1; //Reset Vb, Vc and Vd.

} //End 'Va' For Loop



return(0);

}

Post Wed Oct 02, 2002 12:15 pm 
   Reply with quote  
Guest





FuCKiN9 cod3R NEwBI3EE

Post Wed Oct 16, 2002 2:28 pm 
   Reply with quote  
  Display posts from previous:      
Post new topic Reply to topic

Forum Jump:
Jump to:  
Page 1 of 1

Last Thread | Next Thread  >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 
< Contact Us - Home >

Powered by phpBB: © 2001 phpBB Group
Templates Copyright ©2001, 2002, Nick Mahon.
Converted to phpBB2 Final by Stefan Paulus | phpbb2-users.de