10 guns, 90 rings, all arranged

Source: Internet
Author: User
# Include "stdafx. H "# include <iostream> # include <windows. h> using namespace STD;/* Find all the 90 rings in total for 10 shots, with the number of rings per gun in 1-10 rings */INT result [10] = {0 }; int sum = 0; void display () {for (INT I = 0; I <10; I ++) {cout <result [I] <"";} cout <Endl;} void fun (INT times, int reduce) // The remaining times are being shot, the reduce loop {If (reduce <0 | 10 * Times <reduce) must be played in total. // The number of remaining guns is not enough to return the reduce loop; if (reduce = 0 & times = 0) // The shooting ends {display (); sum ++; // sleep (300); return ;} for (INT I = 10; I> = 1; I --) {result [times-1] = I; // The I ring is played in the countdown times shot, fun (times-1, reduce-I); // In the following times-1 times, the reduce-I ring} int _ tmain (INT argc, _ tchar * argv []) {int times = 10; int reduce = 90; fun (times, reduce); // you need to take 10 shots at the beginning, play the 90-ring cout <sum <Endl; getchar (); Return 0 ;}

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.