#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-10 11:27
明天又是董事长面,啥时候是个头啊
积极向上的林同学:董事长亲自面试
点赞 评论 收藏
分享
06-26 17:24
已编辑
宁波大学 golang
迷失西雅图:别给,纯kpi,别问我为什么知道
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务