021. Two small algorithms

Source: Internet
Author: User

#include <stdio.h>
#include <stdlib.h>
void Main () {
13,21,5,37,8,47,6,89,100,37,5 to number of orders
int l_array[] = {13,21,5,37,8,47,6,89,100,37,5};
int l_length = sizeof (L_array)/sizeof (int);
int l_temp;

for (size_t i = 0; i < l_length-1; i++)
{
for (size_t II = i + 1; ii <= l_length-1; ii++)
{
if (L_array[i] < L_array[ii]) {
L_temp = L_array[ii];
L_ARRAY[II] = L_array[i];
L_array[i] = l_temp;
}
}
}

System ("pause");
}//to Number

#include <stdio.h>
#include <stdlib.h>
void Main () {
Now there are 100 yuan, Rooster 5 yuan/Only, hen 3 yuan/only, chicken 1 Yuan 3 only.
Three kinds of chickens must be bought, and just 100 yuan spent, three kinds of chickens added up to fill 100

int x, y, Z;
for (size_t x = 1; x < + × x + +) {
for (size_t y = 1; y < y++) {
z = 100-x-y;
if (z% 3 = = 0 && ((5 * x) + (3 * y) + (z% 3)) = = 100) {
printf ("Rooster%d hen%d chick%d\n", x, Y, z);
}
}
}
System ("pause");
}

021. Two small algorithms

Related Article

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.