If you enter a four-digit positive integer, call the function (custom function) to output the maximum number of integers.

Source: Internet
Author: User

/*
Input a four-digit positive integer at any time. Call the function (custom function) to output the numbers of All integers.
The maximum number of characters.
*/
# Include <stdio. h>
Int numb (int)
{
Int I = 0, j = 0, sum = 0, B [4];
B [0] = A % 10;
B [1] = A/10% 10;
B [2] = A/100% 10;
B [3] = A/1000;

For (I = 0; I <4; I ++)
{
For (j = 0; j <3-I; j ++)
{
If (B [J]> B [J + 1])
{
B [4] = B [J];
B [J] = B [J + 1];
B [J + 1] = B [4];
}
}
Sum = (sum + B [3-I]) * 10;

}
Return sum/10;

}

Void main ()
{
Int;
Printf ("enter a four-digit positive integer :");
Scanf ("% d", & );
Printf ("% d the maximum number of digits is % d \ n", A, numb ());
}

If you enter a four-digit positive integer, call the function (custom function) to output the maximum number of integers.

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.