Cod sursa(job #1339622)

Utilizator andreeadimaDima Andreea andreeadima Data 11 februarie 2015 00:22:17
Problema Convertor Scor 50
Compilator cpp Status done
Runda Arhiva Monthly Marime 1.15 kb
#include <fstream>
#include <string>
using namespace std;

ifstream fin("convertor.in");
ofstream fout("convertor.out");

char c;

int main()
{
    int g_ok = 0;
    int a_ok = 0;
    do
        {
        fin.read(&c,1);
        }
    while (c != '{');
    do
    {
        fin.read(&c,1);
        if (c == '"')
            g_ok++;
        if (g_ok == 1 && c != '"' )
            fout<<c;
        if ( c == ',')
        {
            g_ok = 0;
            fout<<c;
        }
    }
    while ( c!= '{');
    fin.close();
    fout<<'\n';
    ifstream fin("convertor.in");
    g_ok = 0;
    do
        {
        fin.read(&c,1);
        }
    while (c != '{');
    do
    {
        fin.read(&c,1);
        if (c == '"')
            g_ok++;
        if (g_ok == 2 && c != '"' && c != ':' && c!='{'&& c!='}' && c!=']'&& c != ' '&& c!=',')
            fout<<c;
        if (g_ok == 3 && c != '"')
            fout<<c;
        if ( c == ',')
            {
                g_ok = 0;
                fout<<c;
            }

        if (c == '{')
            fout<<'\n';
    }
    while (c != ']');
    fout<<',';
    return 0;
}