打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
90 f0311 有问题


#include"fstream"
#include"vector"
#include"sstream"
#include"iostream"
using namespace std;
typedef vector<vector<int>> mat;
mat input();
void mysort(mat & a);
void print(const mat & a);
int main()
{
 mat a = input();
 mysort(a);
 print(a);
 system("pause");
 return 0;

}


mat input()
{
 ifstream in("aaa.txt");
 mat a;
 for (string s; getline(in, s);)
 {
  vector<int>b;
  istringstream sin(s);
  for (int ia; sin >> ia;)
  {
   b.push_back(ia);
  }
  a.push_back(b);
 }
 return a;
}

void mysort(mat &a)
{
 for (unsigned int pass = 1; pass<a.size(); ++pass)
 {
  for (unsigned int i = 0; i < a.size() - pass; ++i)
  {
   if (a[i].size() > a[i + 1].size())
   {
    a[i].swap(a[i + 1]);
   }
  }
 }
}

void print(mat &a)
{
 for (unsigned int i = 0; i<a.size(); ++i)
  for (unsigned int j = 0; j < a[i].size(); ++j)
  {
   cout << a[i][j] << "  " << endl;
  }
}


 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
程序员面试金典1.7 清除行列
Mat, vector,Iplimage等等常见类型转换
【深度学习系列(二)】:基于c++实现一个简单的神经网络(1)
点阵字体显示系列补记2:关于24点阵汉字显示程序及其修改版本 | 迟思堂工作室
Mat, vector<point2f>,Point3d Iplimage等等常见类型转换
各种排序算法C++实现(冒泡,选择,插入,快速,归并,堆)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服