#include<stdio.h> #include<malloc.h> #define MAX_SIZE    100 void BubbleSort_high(int *array); int getcount(int r_count, int g_count, int b_count); int getcount(int r_count, int g_count, int b_count) {     int count = 0;          count += r_count;     r_count -= count;     g_count -= count;     b_count -= count;     if((b_count / 2) >= g_count) {         count += g_count;     }else {         count += (b_count / 2);     }     return count; } int main(void) {     int n;     int i,j;     int array[MAX_SIZE][3];     scanf("%d", &n);     for(i = 0; i < n; i++) {         scanf("%d%d%d", &array[i][0],&array[i][1],&array[i][2]);     } //先对得到的每组三个数据排序,第一步找到最小的min3Num  所有的元素减去最小的元素, count = count + min3Num //第二步最大的元素max除以2,和第二大的元素secondMax比较,若大于 count = count + secondMax //max/2 <= secondMax, 那么就让count = count + max / 2; //我还是不知道哪里有问题啊 心态炸了 好绝望啊 是我打扰贵公司了 打扰了     for(i = 0; i < n; i++) {         BubbleSort_high(array[i]);         printf("%d\n", getcount(array[i][0], array[i][1], array[i][2]));     }     return 0; } 想的是先找三个元素最小的 让三个元素都减去最小的,再让最大的除以二和次大的比较,
点赞 3

相关推荐

07-17 11:56
门头沟学院 Java
感谢东子的收留
码农索隆:好好好,优秀优秀
点赞 评论 收藏
分享
Java大菜狗:纯纯招黑奴,一天还不到两百那么多要求,还不迟到早退,以为啥啊,给一点工资做一堆活,还以不拖欠员工工资为荣,这是什么值得骄傲的事情吗,纯纯***公司
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务