提交记录 #511
提交时间:2024-12-17 13:51:01
语言:c
状态:CompileError
编译情况:编译错误
code.c: In function ‘main’:
code.c:18:4: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
18 | gets( sa );
| ^~~~
| fgets
code.c: At top level:
code.c:33:31: error: unknown type name ‘BUY’
33 | int findm(int n, int gp[][3], BUY schm[]) {
| ^~~
固定测试点暂不可用
附加测试点暂不可用
5959-64,H26
int findm(int n, int gp[][3], BUY schm[]) {
int min_total = INT_MAX; // 初始化最小总金额为最大值
int min_A = 0, min_B = 0, min_C = 0; // 记录商品 A、B、C 的最优商店
// 遍历所有可能的商店组合
for (int i = 0; i < n; i++) { // 商品 A 的商店
for (int j = 0; j < n; j++) { // 商品 B 的商店
if (j == i) continue; // 不能在同一个商店购买两种商品
for (int k = 0; k < n; k++) { // 商品 C 的商店
if (k == i || k == j) continue; // 不能在同一个商店购买两种商品
// 计算当前组合的总金额
int total = gp[i][0] + gp[j][1] + gp[k][2];
// 如果当前组合的总金额更小,更新最优方案
if (total < min_total) {
min_total = total;
min_A = i;
min_B = j;
min_C = k;
}
}
}
}