大佬们看看我这个哪里有问题。一直66分
查看原帖
大佬们看看我这个哪里有问题。一直66分
1294648
zajiu楼主2024/3/17 20:46
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main() {
    int nums, m, i, n, s=0, M,j;
    int a[1000];
    cin >> n;//需要买的笔
    for (i = 1; i < 4; i++) {
        cin >> nums >> m;//一包笔的数量和钱
        if (n % nums != 0 && n > nums)
            s = n / nums + 1;//需要的笔比一包的多,不能整除所以加一多买一包
        if (n % nums != 0 && n < nums)
            s = 1;
        if (n % nums == 0)
        s = n / nums;
        M = s * m;
        for (j = i; j < 4; j++)
            a[j] = M;//放到数组里用比较函数
    }
    sort(a, a + 3);
        cout << a[1] << endl;
    return 0;
}
2024/3/17 20:46
加载中...