Yurttas/PL/OOL/Cplusplus/F/07/03/02/00/mmap 00.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2005
 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, 2005.
11   author : Salih Yurttas.
12
13   mmap_00.cpp
14*/
15
16
17#include <iostream>
18
19#include <vector>
20#include <string>
21
22#include <map>
23
24using namespace std;
25
26int main(int argc, char* argv[]) {
27
28  string dna_list[] = {"AGGCTAAT",
29                       "GGCTAATA",
30                       "TGTAAATT",
31                       "ACGAGGCT"};
32  int n = 4;
33
34  int counts_list[] = {2,
35                       2,
36                       4,
37                       1};
38
39  int positions_list0[] = {5,
40                           8};
41
42  int positions_list1[] = {4,
43                           7};
44
45  int positions_list2[] = {1,
46                           3,
47                           7,
48                           8};
49
50  int positions_list3[] = {8};
51
52  for(int i=0; i<n; ++i) {
53    cout << dna_list[i] << " - ";
54    int m = counts_list[i];
55    switch(i) {
56      case 0 : cout << m << " ";
57               for(int j=0; j<m-1; ++j)
58                 cout << positions_list0[j] << ",";
59               cout << positions_list0[m-1] << endl;
60               break;
61      case 1 : cout << m << " ";
62               for(int j=0; j<m-1; ++j)
63                 cout << positions_list1[j] << ",";
64               cout << positions_list1[m-1] << endl;
65               break;
66      case 2 : cout << m << " ";
67               for(int j=0; j<m-1; ++j)
68                 cout << positions_list2[j] << ",";
69               cout << positions_list2[m-1] << endl;
70               break;
71      case 3 : cout << m << " ";
72               for(int j=0; j<m-1; ++j)
73                 cout << positions_list3[j] << ",";
74               cout << positions_list3[m-1] << endl;
75    }
76  }
77
78}