Judy_Angella 2015-03-26 05:22 采纳率: 0%
浏览 3091

我用vector里resize函数创建了一个二维数组,怎么给它排序?代码如下,哪里错了呢?

#include
#include
#include
#include
#include
using namespace std;
int main()
{
int n, m;
cout << "input the row:n and the column:m" << endl;
cin >> n >> m;
vector< vector > array(n);
for (int i = 0; i < n; i++)
array[i].resize(m);
cout << "before sorting" << endl;
srand((signed)time(NULL));
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
array[i][j] = rand() % 101;
cout << array[i][j] << " ";
}
cout << endl;

}
cout << "after sorting" << endl;
for (int i = 0; i < n; i++)
{
    sort(array[i].begin, array[i].end);//运行时系统总说我的这一行是错的,而且有三个错误
    for (int j = 0; j < m; j++)
    {
        cout << array[i][j] << "  ";
    }
    cout << endl;
}

}
运行结果总有三个错误。。。
错误 1 error C3867: “std::vector>::begin”: 函数调用缺少参数列表;请使用“&std::vector>::begin”创建指向成员的指针

错误 2 error C3867: “std::vector>::end”: 函数调用缺少参数列表;请使用“&std::vector>::end”创建指向成员的指针

错误 3 error C2780: “void std::sort(_RanIt,_RanIt,_Pr)”: 应输入 3 个参数,却提供了 2 个

  • 写回答

1条回答 默认 最新

  • oyljerry 2015-03-26 07:52
    关注
     vector< vector <int>> array(n);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大