字符串分割
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ifstream readfile;
readfile.open("八卦图数据源.txt");
string str;
string oldstr="";
do{
readfile>>str;
if(str==oldstr){
break;
}
oldstr=str;
cout<<str<<" x:"<<str.substr(0,str.find(":"))<<" z:"<<str.substr(str.find(":")+1)<<endl;
}while(str.size()>2&&str.find(":")>0&&str.find(":")<str.size());
return 0;
}

浙公网安备 33010602011771号