You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include "类.h"
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
PositionQueue queue;
|
|
|
|
|
|
|
|
|
|
string input_data;
|
|
|
|
|
while (true) {
|
|
|
|
|
getline(cin, input_data);
|
|
|
|
|
if (input_data.empty()) continue; // 如果输入为空,跳过
|
|
|
|
|
|
|
|
|
|
// 解析json
|
|
|
|
|
size_t pos1 = input_data.find("x");
|
|
|
|
|
size_t pos2 = input_data.find(",", pos1+3);
|
|
|
|
|
size_t pos3 = input_data.find("y", pos2+1);
|
|
|
|
|
size_t pos4 = input_data.find(",", pos3+3);
|
|
|
|
|
size_t pos5 = input_data.find("z", pos4+1);
|
|
|
|
|
size_t pos6 = input_data.find("}", pos5+3);
|
|
|
|
|
|
|
|
|
|
if (pos1 == string::npos || pos2 == string::npos || pos3 == string::npos || pos4 == string::npos || pos5 == string::npos || pos6 == string::npos) {
|
|
|
|
|
cout << "输入格式错误,请重新输入" << endl; //string::nops就是最大格式长度
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double x = stod(input_data.substr(pos1+3, pos2-pos1-3));
|
|
|
|
|
double y = stod(input_data.substr(pos3+3, pos4-pos3-3));
|
|
|
|
|
double z = stod(input_data.substr(pos5+3, pos6-pos5-3));
|
|
|
|
|
|
|
|
|
|
queue.insert(Position(x, y, z));
|
|
|
|
|
|
|
|
|
|
queue.output_sorted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|