Pagini recente » Cod sursa (job #2498692) | Cod sursa (job #258657) | Cod sursa (job #3188342) | Cod sursa (job #1359584)
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
ifstream in;
ofstream out;
string buffer;
int begin, end;
int cnt;
in.open("convertor.in");
out.open("convertor.out");
getline(in, buffer, '{');
getline(in, buffer, '}');
cnt = 0;
while (true) {
begin = buffer.find("\"", cnt);
end = buffer.find("\"", begin + 1);
out << buffer.substr(begin + 1, end - begin - 1) << ",";
cnt = buffer.find(",", cnt + 1);
if (cnt == string::npos) {
out << endl;
break;
}
}
while (true) {
while (true) {
begin = buffer.find(":");
if (begin == string::npos) {
out << endl;
break;
}
begin = buffer.find_first_not_of(" \f\n\r\t\v", begin + 1);
if (buffer.at(begin) == '\"') {
begin++;
}
end = buffer.find(",", begin + 1);
end = buffer.find_last_not_of(" \f\n\r\t\v", end - 1);
if (buffer.at(end) == '\"') {
end--;
}
out << buffer.substr(begin, end - begin + 1) << ",";
buffer = buffer.substr(begin);
}
getline(in, buffer, '}');
if (buffer.find(",") == string::npos) {
break;
}
} ;
in.close();
out.close();
return 0;
}