Cod sursa(job #1339641)

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

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

char c;

int main()
{
    int g_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++;
        else {
            if (g_ok == 2  && c != ':' && c!='{'&& c!='}' && c!=']'&& c != ' '&& c!=',' && (int)c!=10)
                fout<<c;
                else
                    if (g_ok == 3 && c != '"')
                        fout<<c;
            if ( c == ',')
                {
                    g_ok = 0;
                    fout<<c;
                }
            else
                if (c == '{')
                    fout<<'\n';}
    }
    while (c != ']');
    fout<<',';

    return 0;
}