-
Notifications
You must be signed in to change notification settings - Fork 0
/
LabelTranslation.cpp
59 lines (57 loc) · 1007 Bytes
/
LabelTranslation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
map<string,int> label_address;
int main(int argc,char *argv[])
{
if(argc > 2){
ifstream fs;
ofstream ft;
fs.open(argv[1]);
ft.open(argv[2]);
string str,temp;
int length = 0;
while(getline(fs,str)){
int n = str.length();
if(str[0] != '_'){
length++;
continue;
}
temp = "";
int j = 0;
while(j < n && str[j] != ':'){
temp += str[j];
j++;
}
label_address[temp] = 2056 + 2 * (length - 8);
}
fs.close();
fs.open(argv[1]);
while(getline(fs,str)){
int n = str.length();
if(str[0] == '_') continue;
for(int i = 0;i < n;i++){
temp = "";
int j = i;
if(str[j] != '_'){
while(j < n && str[j] != ' '){
temp += str[j];
j++;
}
ft << temp << " ";
}
else{
while(j < n){
temp += str[j];
j++;
}
ft << label_address[temp];
}
i = j;
}
ft << endl;
}
}
else
cout << "Porper arguments not given" << endl;
return 0;
}