Joke Collection Website - Joke collection - C++ Chicken and rabbit cage A is the total number of chickens and rabbits, and B is the total number of feet. How many chickens and rabbits are there?
C++ Chicken and rabbit cage A is the total number of chickens and rabbits, and B is the total number of feet. How many chickens and rabbits are there?
I have always been curious about a local tyrant friend who has never studied, but his business is quite big. I visited him today and finally found the answer! His son is doing homework, but he can't solve a problem. Ask us for help! The topic is: chicken and rabbit * *15, * * * has 40 feet, how many chickens and rabbits are there? I replied: "Let the number of chickens be X and the number of rabbits be Y" … I haven't worked out the answer yet, but my friend has given the answer! He said it was strange that you educated people were not disabled. His algorithm is: suppose chickens and rabbits are well trained, whistle and lift one foot, and 40- 15=25. Blow the whistle again and lift one foot, 25- 15= 10. At this time, the chicken is sitting on the ground, and the rabbit is still standing on two feet. So there are 10÷2=5 rabbits, 15-5= 10 chickens. This is why his son always comes first in mathematics. This algorithm makes Olympic math teachers feel embarrassed! I can only feel that I can't see the dead book when I study! Otherwise, we can't beat the local tyrants.
So according to the above algorithm, there is no need to use loops, which is more concise and clear. The process is as follows:
# include & ltiostream.h & gt
Master ()
{
Int chicken, sum foot
Cout & lt& lt "Total number of people =";
CIN & gt; & gt sum;
Cout & lt& ltendl & lt& lt "number of feet =";
CIN & gt; & gt feet;
Chicken = (foot -2 * and)/2;
Cout & lt& ltendl & lt& lt Chicken: "<& lt Chen Chi<< endl & lt" Rabbit: "<<& lt(sum-chicken)& lt; < & ltendl
System ("suspended");
}
- Previous article:Can you provide a junior high school math lesson preparation model?
- Next article:Is verbal sexual harassment illegal?
- Related articles
- Funny phrases to cheer for sports games
- So, how many people hate mahjong players?
- Crosstalk jokes daquan
- How to write the first tweet of WeChat official account?
- Why did Zi Qiao say that girls who love green peppers are not fuel-efficient lights when ipartment played with Friends in the fourth season?
- Let's talk about the reason why you know the joke. Come on!
- I 13 years old, but my hair is all white. What should I do? My classmates laughed at me for bullying me and asked my big brother and sister for help (dyeing my hair).
- A joke about God's answer.
- Tell a little joke about accounting in your own words.
- Jokes about anime lovers