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);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看