void print_in_order(Node *root) { if (root != NULL) { print_in_order(root->left); std::cout << root->value << ' '; print_in_order(root->right); } }
void print_in_order(std::ostream & ostr, const TreeNode<int>* p) { if (p) { print_in_order(ostr, p->left); ostr << p->value << "\n"; print_in_order(ostr, p->right); } }
static void print_in_order(rxt_node * root) { if (!root) return; if (root->color) { if (2 == root->color) root = root->value; printf("%s: %s\n", root->key, (char *) root->value); return; } print_in_order(root->left); print_in_order(root->right); }
int main() { ds_set<int> holder; holder.insert(1); holder.insert(2); holder.insert(3); holder.insert(4); holder.insert(5); holder.insert(6); holder.insert(7); std::ostream ostr; print_in_order(ostr, *holder.begin()); return 0; }
// Produce a histogram of ciphertext character frequencies in a given period and index void histo(int per, int index, FILE *text) { int tot_count = 0; int char_count[ALPHA_LEN]; // Make sure index and period are valid if(per < 1 || index < 1) { fprintf(stderr, "ERROR: period and index must both be at least 1.\n"); return; } else if(index > per) { fprintf(stderr, "ERROR: index must be less than or equal to period.\n"); return; } // Initialize character counts for(int i=0; i<ALPHA_LEN; i++) { char_count[i] = 0; } char* curr_in = (char*)malloc(per); fread(curr_in, 1, index-1, text); // Read all characters from input and add them to char count while(fread(curr_in, 1, per, text)) { // Only read letters if(*curr_in >= 'a' && *curr_in <= 'z') { tot_count++; char_count[*curr_in - 'a']++; } } // Print output print_in_order(char_count, tot_count); free(curr_in); // PSEUDO-CODE // - Seek to first character to read // - Read 'period' bytes from file, // - Take first letter read and add to char count // - Use basic selection sort to pick out the most frequent letters // - Print the letters and count in order }