Cod sursa(job #1344395)

Utilizator irinapatularuPatularu Irina irinapatularu Data 16 februarie 2015 18:09:01
Problema Convertor Scor 70
Compilator c Status done
Runda rosedu_cdl_2015 Marime 1.31 kb
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
    FILE *f,*g;
    char c;
    int ct=0;
    f=fopen("convertor.in","rb");
    g=fopen("convertor.out","w");
    fread(&c,sizeof(char),1,f);
    while(c!='}')
    {
        if(c=='\"')
        {
            ct++;
        }
        else
        {
            if(ct==1)
            {
                fprintf(g,"%c",c);
            }
            else
                if(c==',')
                    {
                        fprintf(g,"%c",c);
                        ct=0;
                    }
        }
        fread(&c,sizeof(char),1,f);
    }
    fprintf(g,"%c\n",',');
    fseek(f,0,SEEK_SET);
    fread(&c,sizeof(char),1,f);
    ct=0;
    while(c!=']')
    {
        if(c=='\"')
            ct++;
        else
        {
            if(c==',' && ct)
                {
                ct=0;
                fprintf(g,"%c",c);
                }
            if(c=='}')
            {
                fprintf(g,"%c\n",',');
                ct=0;
            }
            if(ct==2)
                if(c<='9' && c>='0')
                    fprintf(g,"%c",c);
            if(ct==3)
                fprintf(g,"%c",c);
        }
        fread(&c,sizeof(char),1,f);
    }
    fclose(g);
    fclose(f);
    return 0;
}