代码对齐UVa1593

来源:互联网 发布:图像识别算法 知乎 编辑:程序博客网 时间:2024/05/29 13:17
#include <iostream>#include <vector>#include <string>#include <sstream>using namespace std;int main(){    string line[1800];    int i = 0;    string s;    vector<string> line2;    while(getline(cin,s)){        ++i;        line[i] = s;        line2.push_back(s);      //vector类型添加元素    }    cout<<"----------------output------------------------"<<endl;    for(int k = 1; k <= i; k++){        string x;        string tmp = line[k];        stringstream ss(tmp);           //把tmp这个string类转成stringstream类ss        while(ss >> x) cout<<x<<" ";    cout<<endl;    }        cout<<"----------------output vector--------------"<<endl;    for(int k = 0; k < i; k++){        string x;        string tmp = line2.at(k); //取出vector类型指定位置的元素        stringstream ss(tmp);        while(ss >> x) cout<<x<<" ";    cout<<endl;    }return 0;}



0 0
原创粉丝点击