-
You have a syntax error, the program to implement this is as follows:
#include
#include
using namespace std;
int main()
int ji, tu;
int jji, ttu;
for( tu = 0; tu < 35; tu ++for( ji = 0; ji < 35; ji ++if( (2*ji + 4*tu ) == 94 )if( (ji + tu) == 35 )jji = ji;
ttu = tu;
break;
ji = jji;
tu = ttu;
cout <<"ji = " <
You think you can program the equations of the time trains.
#include
using namespace std;
void main()
int ji,tu;
for(ji=0;ji<=35;ji++)tu = 35 - ji;
if((tu*4+ji*2) == 94)break;
cout<<"ji"<
Hehe. The algorithm is wrong.
You're here to beg. Computers also need to be designed to be sought. You tell him this and you don't tell him how to ask for it.
This is what you need to program to find a binary equation.
The python program of chickens and rabbits in the same cage should be written according to the description in the original book: "There are pheasants and rabbits in the same cage today, with thirty-five heads on the top and ninety-four feet on the bottom. ”The Python program is written as follows:
The translation of the original text into modern Chinese is: "How many chickens and rabbits are there in a cage with 35 heads and 94 claws?" ”
1. According to the title, the total number of headers is 35, and the total number of headers is recorded with the variable head: head = 35. The total number of legs is 94, and the variable foot is used to record the total number of legs: (foot = 94).
2. Use the variable chicken to record the number of chickens. Because the total number of heads is 35, which means that there are 35 chickens and rabbits, the number of chickens is a certain number between 0-35, and here the for loop is used to command the computer to automatically list all possible scenarios: (for chicken in range(0, head+1):
3. Then, record the number of rabbits with the variable rabbit. Because the total number of chickens and rabbits is equal to the number of heads, the number of rabbits is equal to the total number of heads minus the number of chickens (chicken:rabbit=head-one chicken).
4. The chicken has two legs, and the rabbit has four legs, so the total number of legs is: (if chicken *2 + rabbit *4 ==foot:print('Chickens',chicken, 'Rabbits',rabbit)) Execute ** and you're done.
Python programming:
Python programming is a cross-platform computer programming language that is an alternative to the ABC language. Python provides efficient high-level data structures, and slag stools provide simple and effective object-oriented programming.
It is an object-oriented, dynamically typed language that was originally designed to write automation scripts (shells), and is increasingly being used for the development of stand-alone, large-scale projects as versions are updated and new language features are added.
This is very simple, assuming that the number of chickens is x, and the number of rabbits is yx+y=h total head.
2x+4y=f total number of feet (2 feet for chickens, 4 feet for rabbits) to solve this equation.
It can be calculated. x=2h-1/2f
y=1/2f-h
Let's start with the analysis: 2 legs for a chicken.
A rabbit has 4 legs.
Since chickens have 80 more legs than rabbits.
Let's assume that the number of rabbits is x, then the number of chickens is 2*x+(80 2)=2*x+40.
Then you can get an equation for Shanbi.
2*x+40+x=100;
then x=(100-40) 3=20;
Let's abstract it.
Then this equation is 2*x+(y 2)+x=100; i.e. x=(100-y 2) staring at Zen 3; (y is the number of extra feet of the chicken).
get the number of rabbits;
Number of chickens = 100-x;
Programmed like this, it's called dim
xintegerdim
y=80;x=(100-y/2)/3;print rabbit:"xprint
Chickens"(100-x)
Programming is inseparable from mathematical analysis.
Only if you learn math well.
In order to make the best use of programming to solve problems.
Hope it works for you.
Related questions13 answers2024-06-03If there are x chickens, then the rabbits have (100-x), get. >>>More
Chickens and rabbits in the same cage problem list method, chickens and rabbits in the same cage sol10 answers2024-06-03If there are x rabbits, then there are 35-x chickens. 4x+2(35-x)=94 4x+70-2x=94 2x=24 x=24 2x=12 35-12=23 Answer: There are 12 rabbits and 23 chicks.
8 answers2024-06-031.A school arranges dormitories for students. If there are 5 people in each dormitory, 4 people will not be able to accommodate; If there are 6 people in each room, there will be only 4 people in one room, and there will be no occupancy in the two dormitories. Find the number of students in the grade and the number of dormitories. >>>More
6 answers2024-06-03100 steamed buns, 3 for 1 big monk, 1 for 3 small monks; There are x big monks, and they eat steamed buns. >>>More
What are the exercises for chickens and rabbits in the same cage, and what are the questions and ans11 answers2024-06-03Chickens and rabbits have a total of 100 legs, and if you replace chickens with rabbits and rabbits with chickens, there are 92 legs. How many chickens are there? What about rabbits? >>>More