-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplinter.cpp
60 lines (56 loc) · 1.2 KB
/
splinter.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
60
#include<cmath>
#include<string>
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<cstdarg>
#include<algorithm>
#include<cassert>
#include "defs.h"
using namespace std;
ostringstream oMsg;
string encode3toabyte (const string & s) {
string retval;
char c = 48;
int weight = 16;
int i;
for (i = 0; i < s.length(); i += 1) {
if (i % 3 == 0) {
c= 48;
weight = 16;
}
c += weight * nt2num(s[i]);
weight /= 4;
if (i % 3 == 2) retval += c;
}
if (i % 3 != 0) retval += c;
return retval;
}
int main(int argc, char * argv[]) {
int index = atoi(argv[1]);
int modval = atoi(argv[2]);
vector<string> row;
int counter = 0;
while (get_row_whitespace(cin, row)) {
string s = row[0];
string src = revcomp(s);
string sub;
for (int i = index; i < s.length(); i += modval) {
sub += src.at(i);
}
//cout << sub << "\t" << counter << endl;
cout << encode3toabyte(sub) << "\t" << counter << endl;
sub = "";
for (int i = index; i < s.length(); i += modval) {
sub += s.at(i);
}
//cout << sub << "\t" << counter << endl;
cout << encode3toabyte(sub) << "\t" << counter << endl;
counter++;
}
}