Pagini recente » Cod sursa (job #3200895) | Cod sursa (job #792477) | Cod sursa (job #2704716) | Cod sursa (job #1359782) | Cod sursa (job #1359783)
#include <iostream>
#include <stdio.h>
#include <fstream>
using namespace std;
int main()
{
char ch;
FILE *input;
input = fopen("convertor.in", "r");
ofstream output;
output.open("convertor.out",ios::out);
int count = 0;
while((ch = fgetc(input)) != EOF){
if(ch == '{')
count++;
if(count > 1)
break;
if(ch == '\"'){
std::string buffer;
ch = fgetc(input);
while(ch != '\"') {
buffer = buffer + ch;
ch = fgetc(input);
}
output<<buffer<<",";
}
else if(ch == ':'){
ch = fgetc(input);
while(ch == ' ' || ch == '\n'){
ch = fgetc(input);
}
if(isdigit(ch))
while(ch != ' ' && ch != ',' && ch != '}' && ch != '\n'){
ch = fgetc(input);
}
else
if ( ch == '"'){
ch = fgetc(input);
while(ch != '"'){
ch = fgetc(input);
}
}
}
}
fclose(input);
FILE *input2;
input2 = fopen("convertor.in", "r");
while((ch = fgetc(input2)) != EOF){
if(ch == '{')
output<<"\n";
if(ch == ':'){
ch = fgetc(input2);
while(ch == ' ' || ch == '\n'){
ch = fgetc(input2);
}
std::string buffer;
if(isdigit(ch))
while(ch != ' ' && ch != ',' && ch != '}' && ch != '\n'){
buffer += ch;
ch = fgetc(input2);
}
else
if ( ch == '"'){
ch = fgetc(input2);
while(ch != '"'){
buffer += ch;
ch = fgetc(input2);
}
}
output<<buffer<<",";
}
}
fclose(input2);
output.close();
return 0;
}