Yurttas/PL/OOL/Cplusplus/F/02/04/03/14/b 04.cpp

From ZCubes Wiki
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_04.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    if(position>=0)
56      data = data.substr(position,
57                         string::npos);
58
59    cout << endl;
60    cout << "replaced data - ";
61    cout << data;
62    cout << endl;
63
64    cout << endl;
65    cout << "-> Yes|No : ";
66    cin >> yes_no;
67  }
68  while(yes_no=='Y');
69
70}