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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
#include <iostream>
#include <vector>
using namespace std;
template <class T>
vector<double> insertSortNotes(const vector<T> &arr){
unsigned int i, j;
vector<T> sortedArray( arr.size() );
sortedArray = arr;
for(i = 0; i<arr.size();i++){
for(j = i; j<arr.size();j++){
if(sortedArray[i] > sortedArray[j]){
T tmp;
tmp = sortedArray[i];
sortedArray[i] = sortedArray[j];
sortedArray[j] = tmp;
}
}
}
return sortedArray;
}
template <class T>
vector<int> insertSortStringnumbers(const vector<T> &arr){
unsigned int i, j;
vector<T> sortedArray( arr.size() );
sortedArray = arr;
for(i = 0; i<arr.size();i++){
for(j = i; j<arr.size();j++){
if(sortedArray[i] > sortedArray[j]){
T tmp;
tmp = sortedArray[i];
sortedArray[i] = sortedArray[j];
sortedArray[j] = tmp;
}
}
}
return sortedArray;
}
template <class T>
vector<std::string> insertSortLetters(const vector<T> &arr, vector<std::string> lets){
unsigned int i, j;
vector<T> sortedArray( arr.size() );
vector<std::string> sortedLets( lets.size() );
sortedArray = arr;
sortedLets = lets;
for(i = 0; i<arr.size();i++){
for(j = i; j<arr.size();j++){
if(sortedArray[i] > sortedArray[j]){
T tmp;
tmp = sortedArray[i];
sortedArray[i] = sortedArray[j];
sortedArray[j] = tmp;
std::string tmpLet;
tmpLet = sortedLets[i];
sortedLets[i] = sortedLets[j];
sortedLets[j] = tmpLet;
}
}
}
return sortedLets;
}
template <class T>
vector<int> insertSortStringnumbers(const vector<T> &arr, const vector<int> strnums){
unsigned int i, j;
vector<T> sortedArray( arr.size() );
vector<int> sortedStrnums( strnums.size() );
sortedArray = arr;
sortedStrnums = strnums;
for(i = 0; i<arr.size();i++){
for(j = i; j<arr.size();j++){
if(sortedArray[i] > sortedArray[j]){
T tmp;
tmp = sortedArray[i];
sortedArray[i] = sortedArray[j];
sortedArray[j] = tmp;
int tmpStrnum;
tmpStrnum = sortedStrnums[i];
sortedStrnums[i] = sortedStrnums[j];
sortedStrnums[j] = tmpStrnum;
}
}
}
return sortedStrnums;
}
int main ()
{
std::vector<double> unsortedNotes;
std::vector<double> sortedNotes;
std::vector<int> unsortedStringnumbers{2, 4, 3, 5, 4, 3};
//std::vector<int> sortedStringnumbers;
std::vector<std::string> unsortedLetters{"F", "G", "C", "E", "A", "D"};
std::vector<std::string> sortedLetters;
std::vector<double> allUnsortedNotes{1.0, 1.0, 1.0, 1.0, 2.0, 2.0};
std::vector<double> allSortedNotes;
std::vector<int> allUnsortedStringnumbers{2, 4, 3, 5, 4, 3};
std::vector<int> allSortedStringnumbers{2, 4, 3, 5, 4, 3};
std::vector<std::string> allUnsortedLetters{"F", "G", "C", "E", "A", "D"};
std::vector<std::string> allSortedLetters{"F", "G", "C", "E", "A", "D"};
std::vector<std::string> chord(6);
std::vector<std::string> mychord(6);
std::vector<int> chordStringnumbers(6);
std::vector<int> mychordStringnumbers(6);
std::vector<double> subsetUnsortedNotes;
std::vector<std::vector<double> > subsetSortedNotes;
std::vector<std::vector<int> > subsetUnsortedStringnumbers;
std::vector<std::vector<int> > subsetSortedStringnumbers;
std::vector<std::vector<int> > subsetSortedStringnumbers2;
std::vector<std::vector<std::string> > subsetUnsortedLetters;
std::vector<std::vector<std::string> > subsetSortedLetters;
std::vector<std::vector<std::string> > subsetSortedLetters2;
for(int j = 1; j < 7; j++){
allSortedNotes = insertSortNotes(allUnsortedNotes);
allSortedLetters = insertSortLetters(allUnsortedNotes, allUnsortedLetters);
allSortedStringnumbers = insertSortStringnumbers(allUnsortedNotes, allUnsortedStringnumbers);
subsetUnsortedLetters.push_back(allSortedLetters);
subsetUnsortedStringnumbers.push_back(allSortedStringnumbers);
subsetSortedLetters.push_back(allSortedLetters);
subsetSortedStringnumbers.push_back(allSortedStringnumbers);
subsetSortedLetters2.push_back(allSortedLetters);
subsetSortedStringnumbers2.push_back(allSortedStringnumbers);
}
int differentNotes = 0;
vector<int> numOfChordTones;
numOfChordTones.push_back(0);
for(int k = 0, a = 0; k <= allUnsortedLetters.size(); k++){
if(allSortedNotes[k] == allSortedNotes[k+1] || allSortedNotes[k+1] == allSortedNotes[k+2]){
subsetUnsortedLetters[differentNotes][a] = allSortedLetters[a];
subsetUnsortedStringnumbers[differentNotes][a] = allSortedStringnumbers[a];
//std::cout << subsetUnsortedLetters[differentNotes][a];//
a++;
}
if(allSortedNotes[k] < allSortedNotes[k+1]){
differentNotes++;
numOfChordTones.push_back(0);
//std::cout << ';';
}
numOfChordTones[differentNotes] = a;
}
for(int k = 0, dN = 0; dN < differentNotes; k++, dN++){
for(int j = 0; j < subsetSortedLetters.size(); j++){
if(subsetSortedStringnumbers[dN][k] < subsetSortedStringnumbers[dN][k+1]){
vector<int> subsetSortedStringnumbers2a(subsetSortedStringnumbers[dN].begin(), subsetSortedStringnumbers[dN].begin() + numOfChordTones[dN]+1);
vector<std::string> subsetSortedLetters2a(subsetSortedLetters[dN].begin(), subsetSortedLetters[dN].begin() + numOfChordTones[dN]+1);
subsetSortedStringnumbers2[dN] = insertSortStringnumbers(subsetSortedStringnumbers2a);
subsetSortedLetters2[dN] = insertSortLetters(subsetSortedStringnumbers2a, subsetSortedLetters2a);
std::cout << subsetSortedStringnumbers2[dN][j];//Printline
std::cout << ';';
}
}
}
}
|