C basic programming: (1) select all three numbers without repeated numbers from the four numbers.

Source: Internet
Author: User

Question: How many three numbers can be composed of 1, 2, 3, and 4 numbers that are different from each other and have no repeated numbers? What is it?

ProgramAnalysis: Numbers that can be entered in hundreds, ten, and one digit are 1, 2, 3, and 4. Make up all the arrays and then remove those that do not meet the conditions.

Code: 4select3. c

# Include "stdio. H "int main (INT argc, char * ARGs []) {int Limit = 4; count (Limit); Return 0;} int count (INT limit) {int sum = 0, I, J, K, Count = 0; for (I = 1; I <= limit; I ++) {for (j = 1; j <= limit; j ++) {If (J! = I) {for (k = 1; k <= limit; k ++) {If (K! = J & K! = I) {count ++; sum = I * 100 + J * 10 + k; printf ("-- % d", sum); If (count % 2 = 0) {printf ("\ n") ;}}}} 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.