In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use C language to deal with the problem of a hundred dollars and a hundred chickens in the calculation classics, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let the editor take you to know it.
1. Problem description
Zhang Qiujian, an ancient Chinese mathematician, put forward a famous "problem of a hundred dollars and a hundred chickens" in his calculation Classics. A rooster is worth five dollars, a hen is worth three, and three chicks are worth one. Now we have to buy a hundred chickens with a hundred dollars. How many cocks, hens and chicks are each?
two。 Analysis of problems
If you only buy cocks for one hundred dollars, you can buy up to 20 cocks, but the title requires you to buy 100 cocks, so the number of cocks is between 0 and 20. By the same token, the number of hens is between 0 and 33. Here, the number of Roosters, hens and chicks is set to cock, hen and chicken, respectively, and the cock+hen+chicken=100 problem is transformed into a problem of solving indefinite equations:
3. Algorithm idea
For the system of indefinite equations, we can use the method of exhaustive loop to solve it. The range of cock is 020, and the available statement for (cock=0; cock)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.