-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevp.cpp
More file actions
55 lines (49 loc) · 1.17 KB
/
revp.cpp
File metadata and controls
55 lines (49 loc) · 1.17 KB
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
#include<iostream>
using namespace std;
string rev(string s){
string rev = "";
auto comp= [](char c){
if(c == 'A') return 'T';
else if(c == 'T') return 'A';
else if(c == 'C') return 'G';
else if(c == 'G') return 'C';
else return c;
};
for(int i = s.length()-1; i >= 0; i--){
rev += comp(s[i]);
}
return rev;
}
string slice(string s, int j, int i){
string rev = "";
for(int m=0; m<j; m++, i++){
if(s[i] == '\0') return "";
rev += s[i];
}
// cout<<"slice: "<<rev<<"\t"<<rev.size()<<"\n";
return rev;
}
int main(){
cout<<"Enter the string: \n";
string s;
getline(cin, s, '$');
int key=0;
string temp = "";
for(int i=0; i<s.length(); i++){
if(s[i] == '\n'){
key = 1;
continue;
}
if(key == 1){
if(s[i]=='\n') continue;
temp += s[i];
}
}
for(int i=0 ; i<temp.length(); i++){
for(int j=4; j<=12; j++){
if(slice(temp, j, i) == rev(slice(temp, j, i)) && slice(temp, j, i)!= "")
cout << i+1 << " " << j << endl;
}
}
return 0;
}