注册 登录
编程论坛 C++教室

compilation error!哥哥姐姐求解~

sdau_梁伟 发布于 2016-03-19 20:04, 3169 次点击
Getting complication error information failed!
这是我的代码
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct WoodenStick
{
    int length;
    int weight;
};
bool cmp(const WoodenStick &w1, const WoodenStick &w2)
{
    if (w1.length < w2.length&&w1.weight < w2.weight)
        return true;
    else
    return false;
}
void TimeSaving(int n, WoodenStick w[], bool b[])
{
    memset(b, false, sizeof(b));
     b[0] = false;
     int t = 0;
     for (int i = 0; i < n; i++)
     {
         for (int i = t; i < n; i++)
             if (b[i] == false)
             {
                 t = i + 1;
                 break;
             }
         for (int i = t; i < n; i++)
         {
             if (w[i].length >= w[t-1].length&&w[i].weight >= w[t-1].weight)
             {
                 b[i] = true;
             }
         }
     }
}
int main()
{
    WoodenStick ws[100];
    bool b[100];
    int n,TestTimes;
    cin >> TestTimes;
    for (int i = 0; i < TestTimes; i++)
    {   
        int time = 0;
        cin >> n;
        for (int i = 0; i < n; i++)
            cin >> ws[i].length >> ws[i].weight;
        sort(ws, ws + n, cmp);
        TimeSaving(n, ws, b);
        for (int i = 0; i < n; i++)
            if (b[i] == false)
                time++;
        cout << time << endl;
    }
    system("pause");
    return 0;
}
求各位哥哥姐姐帮我看看
1 回复
#2
z11437096082016-03-19 21:17
没仔细看代码,不清楚功能,但是我这边是可以编译通过,
1