Algorithm: QQ grade converted into Crown Sun Star Moon

Source: Internet
Author: User
Tags pow

///<summary>///Level conversion to Icon distribution///In the form of QQ calculation///2^ (2*0)/1///2^ (2*1)/4///2^ (2*2)/16///2^ (2*3)/64///</summary>/// <param name=" Target "> target level </param >/// <param  Name= calculate base </param>/// < Param name=> The maximum number of powers </param>///  <RETURNS></RETURNS>        
Public ienumerable<short> A (double target, double x, int y) {if (Y < 1 | | target <= 0 | | x < 1) {return new short[] {1}; } var r = new Short[y + 1]; for (int i = y; i > 0; i--) {Double A = Math.pow (x, I * 2); R[i] = (short) (target/a); Target-= r[i] * A; } R[0] = (short) target; return R; }

The idea is to reduce each of the iconic levels (4,16,64 ...). The product of the integral. Then record the total level/each iconic level, the result is how many patterns (Crown, sun ...). From the largest to the small pattern calculation, to the end is how many first-level patterns (stars)

If each of the iconic levels is not calculated by Math.pow (x, I * 2), the value formula should be replaced by something else.

A (lv,2,4)

Reference Links:


Algorithm: QQ grade converted into Crown Sun Star Moon

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: 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.