Pagini recente » Cod sursa (job #935277) | Cod sursa (job #59849) | Cod sursa (job #3292472) | Cod sursa (job #3139541) | Cod sursa (job #1360025)
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
#define FIN "convertor.in"
#define FOUT "convertor.out"
int main()
{
vector <string> elements;
string str;
char c;
int H, fline, i;
freopen(FIN, "r", stdin);
freopen(FOUT, "w", stdout);
for (fline = 1; scanf("%c", &c); )
{
if (c < 33)
continue;
if (c == '"')
{
for (str.clear(), scanf("%c", &c); c != '"'; scanf("%c", &c))
if (fline)
printf("%c", c);
if (fline)
printf(",");
//if (fline)
//printf("%s,", str.c_str());
}
if (c == ':')
{
for (scanf("%c", &c); c < 33; scanf("%c", &c));
if (c == '"')
for (str.clear(), scanf("%c", &c); c != '"'; scanf("%c", &c))
str.push_back(c);
else
for (str.clear(); c >= '0' && c <= '9'; scanf("%c", &c))
str.push_back(c);
if (fline)
elements.push_back(str);
else
printf("%s,", str.c_str());
}
if (c == '}' && fline)
{
fline = 0;
H = elements.size();
printf("\n");
for (i = 0; i < H; ++ i)
printf("%s,", elements[i].c_str());
}
if (c == '{' && !fline)
printf("\n");
if (c == ']')
break;
}
printf("\n");
}