1 #include <iostream>
2 #include <string>
3 #include <fstream>
4 using namespace std;
5
6 int main() {
7 ifstream ifs("tuan.sql", ifstream::in);
8 ofstream ofs("trv.txt", ofstream::out);
9 string s,value;
10 char c1;
11 int start_pos=0,end_pos=0;
12 while(!ifs.eof() && !ifs.fail()) {
13 ifs >> s;
14 if(s[0] == '(') {
15 value += s;
16 continue;
17 }
18 int len = s.length();
19 for(int index=0; index<len;) {
20 if((index+1) <= len) {
21 c1 = s[index++];
22 if(c1==')'&&index!=len&&s[index]==',') {
23 end_pos = index;
24 value += " ";
25 value += s.substr(start_pos, end_pos);
26 value += "\n";
27 ofs << value;
28 value.clear();
29
30 start_pos = index + 1;
31 value += s.substr(start_pos,len);
32 start_pos=end_pos=0;
33 break;
34 }
35 if(c1==')'&&index==len) {
36 value += " ";
37 value += s;
38 value += "\n";
39 ofs << value;
40 value.clear();
41 start_pos=end_pos=0;
42 }
43 }else {
44 break;
45 }
46 }
47 }
49 ifs.close();
50 ofs.close();
51 return 0;
52 }