Yurttas/PL/OOL/Cplusplus/F/02/04/03/14/b 14.cpp
Jump to navigation
Jump to search
1/*
2 Copyright(C) 2004
3 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for EDUCATIONAL purposes
7 and without fee is hereby granted provided that this
8 copyright notice appears in all copies.
9
10 date : September 1, 2004.
11 author : Salih Yurttas.
12
13 b_14.cpp
14*/
15
16
17#include <iostream>
18#include <string>
19
20using namespace std;
21
22int main(int argc, char* argv[]) { // this is not programming!
23 // the whole world does programming like this!
24 string data = "AAGCAAGCTAA"; // we need to correct this and
25 // we'll correct this.
26
27 cout << endl;
28 cout << "given data - ";
29 cout << data;
30 cout << endl;
31
32 char yes_no;
33
34 do {
35 string pattern;
36
37 cout << endl;
38 cout << "-> pattern : ";
39 cin >> pattern;
40
41 cout << endl;
42 cout << "pattern - ";
43 cout << pattern;
44 cout << endl;
45
46 int length = pattern.length();
47
48 int position = data.find(pattern);
49
50 cout << endl;
51 cout << "matching position - ";
52 cout << position;
53 cout << endl;
54
55 string replaced_data = data;
56
57 if(position>=0)
58 replaced_data = data.substr(position,
59 string::npos);
60
61 cout << endl;
62 cout << "replaced data - ";
63 cout << replaced_data;
64 cout << endl;
65
66 cout << endl;
67 cout << "-> Yes|No : ";
68 cin >> yes_no;
69 }
70 while(yes_no=='Y');
71
72}