Crazy guy C-learn to edit code

Source: Internet
Author: User

/*
The father assigned 2520 oranges to six sons. After the split, the father said:
"The old man gave you 1/8 of the oranges to the second man;
After obtaining the result, the second child scores 1/7 of the original oranges to the third child;
After the old Three get the result, they divide the original oranges into 1/6 for the old four;
After getting the old four, they allocated 1/5 oranges to the old five;
After getting the old five, they allocated 1/4 oranges to the old six;
After getting the old six, we allocated 1/3 yuan to the boss together with the original oranges ".
There is no orange score in the process of dividing,
As a result, there are just as many oranges in your hands. Ask the six brothers how many oranges they have.
*/
# Include <stdio. h>
# Include <stdlib. h>

# Define JUZI_ZONGSHU 2520
# Define FENSHU 6

# Define XD1_XD2 8
# Define XD2_XD3 7
# Define XD3_XD4 6
# Define XD4_XD5 5
# Define XD5_XD6 4
# Define XD6_XD1 3

Int main (void)
{
Int xd1, xd2, xd3, xd4, xd5, xd6; // The number of oranges of the brothers

// The result is that there are as many oranges in your hands.
Xd1
= Xd2
= Xd3
= Xd4
= Xd5
= Xd6
= JUZI_ZONGSHU/FENSHU;

// Before giving the old six to the boss
Xd6 = xd6/(XD6_XD1-1) * XD6_XD1;
Xd1-= xd6/XD6_XD1;

// Before assigning the old five to the old six
Xd5 = xd5/(XD5_XD6-1) * XD5_XD6;
Xd6-= xd5/XD5_XD6;

// Before the old four are assigned to the old five
Xd4 = xd4/(XD4_XD5-1) * XD4_XD5;
Xd5-= xd4/XD4_XD5;

// Before the old Three are assigned to the old four
Xd3 = xd3/(XD3_XD4-1) * XD3_XD4;
Xd4-= xd3/XD3_XD4;

// Before the second child is assigned to the third child
Xd2 = xd2/(XD2_XD3-1) * XD2_XD3;
Xd3-= xd2/XD2_XD3;

// Before the boss gives it to the second child
Xd1 = xd1/(XD1_XD2-1) * XD1_XD2;
Xd2-= xd1/XD1_XD2;


Printf ("the number of oranges in the old hands of the six brothers is :");
Printf ("% d ",
Xd1, xd2, xd3, xd4, xd5, xd6 );


System ("PAUSE ");
Return 0;
}
Beginners often write code with one character at a time, which is not only inefficient but also prone to errors. You should learn to edit code efficiently and easily without errors.
Take the code in this question as an example:
// Before giving the old six to the boss
Xd6 = xd6/(XD6_XD1-1) * XD6_XD1;
Xd1-= xd6/XD6_XD1;
Red identifiers should be copied and pasted. This method is not prone to errors and is highly efficient.
The two lines of code after "// old five to old six" should be copied after the first two lines of code, you can do this by searching, replacing, copying, and pasting. Subsequent lines of code should also be processed in accordance with the law.
Be sure to get rid of the character-by-character edit code habit.
Green Channel: Please follow my favorites to contact me

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.