Yurttas/PL/OOL/Cplusplus/F/07/03/02/00/mmap 11.cpp
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_11.cpp
14*/
15
16#include <iostream>
17
18#include <vector>
19#include <string>
20
21#include <map>
22
23using namespace std;
24
25int main(int argc, char* argv[]) {
26
27 string dna_list[] = {"AGGCTAAT",
28 "GGCTAATA",
29 "TGTAAATT",
30 "ACGAGGCT"};
31 const int N = 4;
32
33 int counts_list[] = {2,
34 2,
35 4,
36 1};
37
38 int positions_list[][4] = {5, 8, 0, 0,
39 4, 7, 0, 0,
40 1, 3, 7, 8,
41 8, 0, 0, 0};
42
43 struct dna_counts_positions { string dna;
44 int count;
45 int positions[N];
46 };
47
48 struct dna_counts_positions dna_counts_positions_list[N];
49
50 for(int i=0; i<N; ++i) {
51 dna_counts_positions_list[i].dna = dna_list[i];
52 dna_counts_positions_list[i].count = counts_list[i];
53 for(int j=0; j<N; ++j)
54 dna_counts_positions_list[i].positions[j] = positions_list[i][j];
55 }
56
57 for(int i=0; i<N; ++i) {
58 cout << dna_counts_positions_list[i].dna << " - ";
59 int m = dna_counts_positions_list[i].count;
60 cout << m << " ";
61 for(int j=0; j<m-1; ++j)
62 cout << dna_counts_positions_list[i].positions[j] << ",";
63 cout << dna_counts_positions_list[i].positions[m-1] << endl;
64 }
65
66}