-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCountN.cpp
More file actions
42 lines (41 loc) · 825 Bytes
/
CountN.cpp
File metadata and controls
42 lines (41 loc) · 825 Bytes
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
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int nl=0, nh=0, other=0;
vector<int> low(256,0), high(256,0);
string prevTitle = "";
while (cin) {
string line;
cin >> line;
if (line.size() > 0 and line[0] == '>') {
if (prevTitle != "") {
int s=nl+nh;
if (s > 0) {
cout << prevTitle << "\t"<< nl / ((float)s) << "\t" << nl << "\t" << nh << endl;
}
else {
cout << prevTitle << "\t0\t0\t0" << endl;
}
}
nl=0; nh=0;
prevTitle = line.substr(1);
}
for (int i=0; i < line.size(); i++) {
if (line[i] == 'N') {
nl+=1;
}
else {
nh+=1;
}
}
}
int s=nl+nh;
if (s > 0) {
cout << prevTitle << "\t"<< nl / ((float)s) << "\t" << nl << "\t" << nh<< endl;
}
else {
cout << prevTitle << "\t0\t0\t0" << endl;
}
}