Pagini recente » Cod sursa (job #1526363) | Cod sursa (job #68779) | Cod sursa (job #57150) | Cod sursa (job #2857010) | Cod sursa (job #1360631)
#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))
str.push_back(c);
if (fline)
{
fputs(str.c_str(), stdout);
putchar(',');
}
}
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
{
fputs(str.c_str(), stdout);
putchar(',');
}
}
if (c == '}' && fline)
{
fline = 0;
H = elements.size();
putchar('\n');
for (i = 0; i < H; ++ i)
{
fputs(elements[i].c_str(), stdout);
putchar(',');
}
}
if (c == '{' && !fline)
putchar('\n');
if (c == ']')
break;
}
putchar('\n');
}