用户工具

站点工具


c

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
c [2022/12/16 23:12]
admin
c [2022/12/16 23:23] (当前版本)
admin
行 72: 行 72:
  return result;  return result;
 } }
 +ifstream fin(inputFile);​ //​打开文件流操作
 + ofstream fin_new(outputFile);​
 + string line;
 + int rollnum, count = 0;
 + vector<​vector<​int>>​ vec;
 + while (getline(fin,​ line)) ​  //​整行读取,换行符“\n”区分,遇到文件尾标志eof终止读取
 + {
 + count++;
 + cout << "​line"​ << count<<"​:"​ << line << endl; //​整行输出
 + istringstream sin(line); //​将整行字符串line读入到字符串流istringstream中
 + vector<​string>​ row; //​声明一个字符串向量
 + string word;
 + while (getline(sin,​ word, ','​)) //​将字符串流sin中的字符读入到word字符串中,以逗号为分隔符
 + {
 + row.push_back(word);​ //​将刚刚读取的字符串添加到向量row中
 + }
 + vector<​int>​ v1;
 + for (int i = 0; i < row.size(); i++) {
 + v1.push_back(stoi(row[i]));​
 + }
 + vec.push_back(v1);​
 + }
 +     ​fin_new << vec[j][i];
 +     ​fin_new.close();​
 +     ​fin.close();​
 +     
 +     //​Point类,运算符重载
 +     #​include <​iostream>​
 +class Point
 +{
 + public:
 + Point(double x,double y):​_x(x),​_y(y){};​
 + bool operator >(const Point& p)
 + {
 + return (_x*_x+_y*_y)>​(p._x*p._x+p._y*p._y);​
 + }
 + bool operator ==(const Point& p)
 + {
 + return (_x*_x+_y*_y)==(p._x*p._x+p._y*p._y);​
 + }
 + bool operator <(const Point& p)
 + {
 + return (_x*_x+_y*_y)<​(p._x*p._x+p._y*p._y);​
 + }
 + private:
 + double _x;
 + double _y;
 + friend std::​ostream&​ operator<<​(std::​ostream&​ os,const Point &point)
 + {
 + os<<"​Point:​("<<​point._x<<","<<​point._y<<"​)\n";​
 + return os;
 + }
 +
 +};
 </​code>​ </​code>​
c.1671203523.txt.gz · 最后更改: 2022/12/16 23:12 由 admin