void main() { char op = 's', l; int x, tam; char *letras; do { letras = digiteLetra(); tam = strlen(letras); printf("Digite a opção desejada:\n1. Insertion Sort\n2. Selection sort\n3. Bubble sort\n4. Comb sort\n5. Merge sort\nSua escolha: "); scanf("%d", &x); switch(x) { case 1: insertionSort(letras, tam); break; case 2: selectionSort(letras, tam); break; case 3: bubbleSort(letras,tam); break; case 4: combSort(letras, tam); break; case 5: fazMergeSort(letras, tam); break; }; printf("Deseja continuar? [s/n]: "); scanf("%s", &op); } while (op == 's'); system("pause"); }
void SFX::scanFiles(uint8_t index) { // First get the files, // then sort the files, // finally assign location info. memset(m_location, 255, sizeof(SFXLocation)*NUM_SFX_TYPES); m_numFilenames = 0; // Serial.print("scanFiles "); Serial.println(index); File root = SD.open(m_dirName[index].c_str()); while (true) { File entry = root.openNextFile(); if (!entry) { // no more files break; } if (entry.isDirectory()) { continue; } else { int slot = calcSlot(entry.name()); if (slot >= 0 && m_numFilenames < MAX_SFX_FILES) { m_filename[m_numFilenames++] = entry.name(); } } entry.close(); } root.close(); // They often come in weird order, which is a bummer. // Simple sort seems fast enough. combSort(m_filename, m_numFilenames); for (int i = 0; i < m_numFilenames; ++i) { addFile(m_filename[i].c_str(), i); } Log.p("IDLE ").p(m_location[SFX_IDLE].start).p(" ").p(m_location[SFX_IDLE].count).eol(); Log.p("MOTION ").p(m_location[SFX_MOTION].start).p(" ").p(m_location[SFX_MOTION].count).eol(); Log.p("IMPACT ").p(m_location[SFX_IMPACT].start).p(" ").p(m_location[SFX_IMPACT].count).eol(); Log.p("USER_TAP ").p(m_location[SFX_USER_TAP].start).p(" ").p(m_location[SFX_USER_TAP].count).eol(); Log.p("USER_HOLD ").p(m_location[SFX_USER_HOLD].start).p(" ").p(m_location[SFX_USER_HOLD].count).eol(); Log.p("POWER_ON ").p(m_location[SFX_POWER_ON].start).p(" ").p(m_location[SFX_POWER_ON].count).eol(); Log.p("POWER_OFF ").p(m_location[SFX_POWER_OFF].start).p(" ").p(m_location[SFX_POWER_OFF].count).eol(); readIgniteRetract(); }
void SFX::scanFonts() { m_numFonts = 0; // Serial.println("scanFonts()"); File root = SD.open("/"); while (true) { File entry = root.openNextFile(); if (!entry) { // no more files break; } if (entry.isDirectory()) { // Scan for a sound font with a limited, reasonable set of files. static const int N = 4; const char* NAMES[N] = { "HUM.WAV", "IDLE.WAV", "POWERON.WAV", "IGNITE.WAV" }; for (int i = 0; i < N; ++i) { CStr<25> path; filePath(&path, entry.name(), NAMES[i]); File file = SD.open(path.c_str()); if (file) { m_dirName[m_numFonts++] = entry.name(); file.close(); break; } } } entry.close(); } root.close(); combSort(m_dirName, m_numFonts); Log.p("Fonts:").eol(); for (int i = 0; i < m_numFonts; ++i) { Log.p(i).p(": ").p(m_dirName[i].c_str()).eol(); } }
int main() { //Print initial array printf("\n//=====Shuffled array===================//"); setarray(); printarray("Initial Array"); //=====Simple sorts=====// printf("\n\n//=====Simple sorts====================//"); //Insertion sort setarray(); insertionSort(array,10); printarray("InsertionSort"); //Selection sort setarray(); selectionSort(array,10); printarray("SelectionSort"); //=====Eficient Sorts=====// printf("\n\n//=====Eficient sorts==================//"); //Mergesort setarray(); mergeSort(array,0,9,10); printarray("MergeSort"); //Heapsort setarray(); heapSort(array,10); printarray("HeapSort"); //Quicksort setarray(); quickSort(array,0,9); printarray("QuickSort"); //Bubble sort and variants printf("\n\n//=====Bubble sort and variants========//"); //Bubblesort setarray(); bubbleSort(array,10); printarray("BubbleSort"); //Shellsort setarray(); shellSort(array,10); printarray("ShellSort"); //Combsort setarray(); combSort(array,10); printarray("CombSort"); //Distribution sorts printf("\n\n//=====Distribution sorts==============//"); //Countingsort setarray(); countingSort(array, 10, 0, 99); printarray("CountingSort"); //Radixsort setarray(); radixSort(array, 10); printarray("RadixSort"); //Other sorts printf("\n\n//=====Other sorts=====================//"); //Gnomesort setarray(); gnomeSort(array,10); printarray("GnomeSort"); //Cyclesort setarray(); cycleSort(array,10); printarray("CycleSort"); printf("\n\n"); }