#include<stdio.h>
#include<stdlib.h>
void main() {
//13,21,5,37,8,47,6,89,100,37,5 给数排序
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");
}//给数
#include<stdio.h>
#include<stdlib.h>
void main(){
//现在有100元,公鸡5元/只,母鸡3元/只,小鸡1元3只.
//要求三种鸡必须都买, 并且正好把100元花完, 三种鸡加起来凑足100只
int x , y , z ;
for (size_t x = 1; x < 21; x++) {
for (size_t y = 1; y < 34; y++) {
z = 100 - x - y;
if (z % 3 == 0 && ((5 * x) + (3 * y) + (z % 3)) == 100) {
printf("公鸡%d 母鸡%d 小鸡%d\n", x, y, z);
}
}
}
system("pause");
}