Home > database >  In a cage, chicken and rabbit has a total of 10, only two more than the rabbit and chicken chicken a
In a cage, chicken and rabbit has a total of 10, only two more than the rabbit and chicken chicken a

Time:05-01

In a cage, chicken and rabbit has a total of 10, only two more than the rabbit and chicken chicken and rabbit each have a few? Write a c program

CodePudding user response:

INT A=0;
INT B=2;
INT SUM;
FOR (SUM=2; SUM<10; SUM++)
{
+;
B++;
};

CodePudding user response:

No, not sum++ are, the sum=sum + 2

CodePudding user response:

refer to the second floor kun jins kao kun jins kao response:
no,, not sum++ is sum=sum + 2

Still won't do ah, a warning, a mistake

CodePudding user response:

reference 1/f, kun jins kao kun jins kao response:
INT A=0;
INT B=2;
INT SUM;
FOR (SUM=2; SUM<10; SUM++)
{
+;
B++;
};

This is wrong, don't run

CodePudding user response:

This line is simple, total is divided by 2, plus half the difference is more, divided by the total 2 minus half of the difference is small,

Such as the total number of 10, the difference is 2, more is 10/2 + 2/2=6, is less 10/2-2/2=4

If the number is 11, the difference is 3, more is 1 1/2 + 3/2=7, less is 1 1/2-3/2=4
  • Related