A number of 10 digits and a single swap and the thought of ...

Source: Internet
Author: User
Today encountered a problem, that is, a >10 and <100 number of digits and 10-bit swap, the first thought and adopted the method is, the decomposition of two numbers to swap and add up:

/* AB is the source number, BA is the number of results * *
Solution: BA = (ab-(AB/10)) * + (AB/10)

Suddenly there is a very strange idea, can you use subtraction? After observation, we found that the number of sources and the number of results added two, to get a number of loops ... Then use subtraction can also achieve ...

such as: 35 after the number of swap
53 = (5+3) *10 + (5+3)-35
= 88-35

such as: 47 after the number of swap
74 = (7+4) *10 + (7+4)-47
= 121-47

...
...

So far, a formula has been summed up:

ba = ((AB/10) + (ab-(AB/10) *10)) * + ((AB/10) + (ab-(AB/10) *10))-AB

Of course, the formula can only be used on the computer, in mathematics is not tenable ...
Although it is a point of trouble, but finally is a new reverse method, has not found any practical value, as the development of a creative in the process, hehe, perhaps one day in some cases this idea will apply ...
This makes me think of the enterprise invoicing system, the actual operation of thinking and our software developers have a lot of thinking is the opposite, for example

A, the general software developers thinking for sales: Each of the generated sales multiplied by the sales price, and then calculated the gross profit margin
B, and the actual operation of thinking for sales: Each volume multiplied by the cost unit price and divided by (1-book gross margin), to obtain sales

It can be seen that the A method, although the most accurate, but there is a big drawback is that there is no predictability and decision-making, while the B method is different, although in the final settlement will be a little bit of error, but can provide a lot of predictability and decision-making, can be very convenient to calculate the future sales. In fact, in practice, method A is completely wrong, because the developer of the gross margin and the relationship between the price of the reverse, the gross margin of goods is not determined by the sales price, but the sale price is determined by the gross margin. How to make the sale price of goods, how can the merchant get the sale price of the goods? It's not a random plan, huh? The usual method is: sales price = Commodity cost Unit Price/(1-to achieve the gross margin), the same, sales = the cost of goods/(1-to achieve the gross profit margin), because for the merchant, a commodity to achieve how the gross margin is known.
Think of the first contact with this B method, the feeling of the epiphany, can not help but sigh with regret is really cool a way ... Of course, the database system still has to use method A to achieve, to ensure that the actual accurate data and accurate statistics, the reality and the system to achieve a number of differences.
Business knowledge and development technology need our developers to learn, is more tired, but the feeling is that in the business knowledge of learning and familiarity often can bring us a lot of interesting creative developers, make the program can cater to the application of customers, hehe
Work all night, really tired, constantly yawning in ...


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.