本文整理汇总了C++中print_all函数的典型用法代码示例。如果您正苦于以下问题:C++ print_all函数的具体用法?C++ print_all怎么用?C++ print_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main () {
Link* norse_gods = new Link("Thor");
norse_gods = norse_gods->insert(new Link("Odin"));
norse_gods = norse_gods->insert(new Link("Zeus"));
norse_gods = norse_gods->insert(new Link("Freia"));
Link* greek_gods = new Link("Hera");
greek_gods = greek_gods->insert(new Link("Athena"));
greek_gods = greek_gods->insert(new Link("Mars"));
greek_gods = greek_gods->insert(new Link("Poseidon"));
Link* g = greek_gods->find("Mars");
if (g) g->value = "Ares";
Link* n = norse_gods->find("Zeus");
if (n == norse_gods) norse_gods = n->next();
n->erase();
greek_gods = greek_gods->insert(n);
print_all(norse_gods);
cout << "======================" << endl;
print_all(greek_gods);
keep_window_open();
}
示例2: main
int main()
{
Link* gods = new Link{God{"Athena", "Greek", "", "knowledge"}};
gods = gods->insert(new Link{God{"Loki", "Norse", "", "Loki's staff"}});
gods = gods->insert(new Link{God{"Poseidon", "Greek", "", "water"}});
gods = gods->insert(new Link{God{"The Many-Faced", "ASoIaF", "masks", "death"}});
gods = gods->insert(new Link{God{"Zeus", "Greek", "", "lightning"}});
gods = gods->insert(new Link{God{"R'hllor", "ASoIaF", "prayer", "fire"}});
gods = gods->insert(new Link{God{"Thor", "Norse", "Rainbow Bridge", "Mjolnir"}});
gods = gods->insert(new Link{God{"The Other", "ASoIaF", "dead things", "ice"}});
gods = gods->insert(new Link{God{"Odin", "Norse", "Sleipner", "Gungir"}});
Link* greek_gods;
Link* norse_gods;
Link* iceandfire_gods;
while (gods) {
if (gods->value.mythology == "Greek") {
greek_gods = greek_gods->insert(new Link{gods->value});
}
else if (gods->value.mythology == "Norse") {
norse_gods = norse_gods->insert(new Link{gods->value});
}
else if (gods->value.mythology == "ASoIaF") {
iceandfire_gods = iceandfire_gods->insert(new Link{gods->value});
}
gods = gods->next();
}
print_all(iceandfire_gods);
print_all(norse_gods);
print_all(greek_gods);
}
示例3: main
int main() {
Link* norse_gods = new Link {"Thor"};
norse_gods = norse_gods->insert( new Link {"Odin"});
norse_gods = norse_gods->insert(new Link {"Zeus"});
norse_gods = norse_gods->insert(new Link {"Loki",});
Link* greek_gods = new Link {"Hera"};
greek_gods = greek_gods->insert(new Link {"Athena"});
greek_gods = greek_gods->insert(new Link {"Mars"});
greek_gods = greek_gods->insert(new Link {"Poseidon"});
Link* p = greek_gods->find("Mars");
//std::cout << norse_gods->succ->value << " : " << greek_gods->succ->value << std::endl;
if (p) p->value = "Ares";
//std::cout << norse_gods->succ->value << " : " << greek_gods->succ->value << std::endl;
Link* p2 = norse_gods->find("Zeus");
if (p2) {
if (p2 == norse_gods) norse_gods = norse_gods->next();
p2->erase();
greek_gods = greek_gods->insert(p2);
}
//std::cout << norse_gods->value << " : " << greek_gods->succ->value << std::endl;
print_all(norse_gods);
greek_gods = greek_gods->add(new Link {"Hades"});
greek_gods = greek_gods->previous();
print_all(greek_gods);
/*Chapter 17 Exercise 12
Why did we define two versions of find()?
*/
const Link* const_test = new const Link {"Test"};
const Link* sp = const_test->find("Test");
std::cout << sp->value << std::endl;
std::cout << greek_gods->previous() << std::endl;
}
示例4: main
int main()
{
print_all(1, 3.14, 'c', "Hello");
std::cout << std::endl;
print_all(1, 'c');
}
示例5: print_all
void print_all(TREE_NODE *root, print_function f, int level){
if (root)
{
f(root, level);
print_all(root->left, f, level + 1);
print_all(root->right, f, level + 1);
}
}
示例6: main
int main(void){
int a[] = {2, 8, 5, 1, 9, 4};
print_all(a, ARRAY_LEN(a));
printf("\n");
insertion_sort(a, ARRAY_LEN(a));
printf("\n");
print_all(a, ARRAY_LEN(a));
return 0;
}
示例7: main
int main()
{
// norse gods
God god_temp = God{"Thor", "A chariot pulled by two goats (that he eats and"
" resurrects", "Mountain-crushing hammer called Mjolnir",
Mythology::Norse};
Link* norse_gods{new Link{god_temp, nullptr, nullptr}};
god_temp = God{"Odin", "Eight-legged flying horse called Sleipnir",
"Spear called Gungnir", Mythology::Norse};
norse_gods = norse_gods->add_ordered(new Link{god_temp});
god_temp = God{"Freia", "A chariot pulled by two cats", "A feathered cloak",
Mythology::Norse};
norse_gods = norse_gods->add_ordered(new Link{god_temp});
// greek gods
god_temp = God{"Zeus", "The Chariot of Zeus", "Thunderbolts",
Mythology::Greek};
Link* greek_gods{new Link{god_temp, nullptr, nullptr}};
god_temp = God{"Athena", "None", "An extremely long spear", Mythology::Greek};
greek_gods = greek_gods->add_ordered(new Link{god_temp});
god_temp = God{"Ares", "His war chariot", "A spear and helmet",
Mythology::Greek};
greek_gods = greek_gods->add_ordered(new Link{god_temp});
god_temp = God{"Poseidon", "A chariot pulled by a winged hippocampus, or"
" horses that can ride on the sea itself", "A trident",
Mythology::Greek};
greek_gods = greek_gods->add_ordered(new Link{god_temp});
// Egyptian gods
god_temp = God{"Osiris", "None", "A crook and flail", Mythology::Egyptian};
Link* egypt_gods{new Link{god_temp, nullptr, nullptr}};
god_temp = God{"Ra", "The sun", "The power of creation", Mythology::Egyptian};
egypt_gods = egypt_gods->add_ordered(new Link{god_temp});
god_temp = God{"Shu", "The wind", "Power to hold up the sky",
Mythology::Egyptian};
egypt_gods = egypt_gods->add_ordered(new Link{god_temp});
print_all(norse_gods);
std::cout << '\n';
print_all(greek_gods);
std::cout << '\n';
print_all(egypt_gods);
std::cout << '\n';
return 0;
}
示例8: main
void main(void) {
printf("[+] Creating a Linked-list 1~5.\n");
NodePtr testData = create_list(1,5);
print_all(testData);
puts("Let me swap it adjacently! swap(3,4)");
swap(testData,testData->next->next,testData->next->next->next);
print_all(testData);
puts("Let me change between head and tail. swap(1,5)");
NodePtr tail=testData;
while(tail->next) tail = tail->next;
print_all(swap(testData,testData,tail));
}
示例9: print_last_n
void print_last_n(LIST* head, int n, FILE* g) {
int na = list_length(head);
if (n >= na) {
print_all(head, g);
} else {
LIST* t = head;
for (int i = 0; i < na - n; i++) {
t = t->next;
}
print_all(t, g);
}
}
示例10: print_all
void print_all(struct node obj){
if(&obj!=NULL){
if(obj.name=='S'||obj.name=='I'||obj.name=='D'||obj.name=='C'){
if(obj.prev!=NULL)
print_all(*obj.prev);
if(obj.value!=NULL) {
print_node(obj);
}
if(obj.next!=NULL)
print_all(*obj.next);
}
}
}
示例11: main
int main()
{
Link* norse_gods = new Link("Thor");
norse_gods = norse_gods->insert(new Link("Odin"));
norse_gods = norse_gods->insert(new Link("Zeus"));
norse_gods = norse_gods->insert(new Link("Freia"));
Link* greek_gods = new Link("Hera");
greek_gods = greek_gods->insert(new Link("Athena"));
greek_gods = greek_gods->insert(new Link("Mars"));
greek_gods = greek_gods->insert(new Link("Poseidon"));
Link* p = greek_gods->find("Mars");
if (p) p->value = "Ares";
// Move Zeus into his correct Pantheon:
{
Link* p = norse_gods->find("Zeus");
if (p) {
if (p==norse_gods)
norse_gods = p->next();
p->erase();
greek_gods = greek_gods->insert(p);
}
}
norse_gods->add(new Link("loki"));
// Finally, let's print out those lists:
print_all(norse_gods);
cout<<"\n";
norse_gods=norse_gods->advance(2); // test advance
print_all(norse_gods);
cout<<"\n";
print_all(greek_gods);
cout<<"\n";
cout<<greek_gods->node_count()<<endl; // test node count
Link* god_list=new Link("Apollo");
god_list=god_list->add(new Link("Aphrodite"));
god_list=god_list->add(new Link("Artemis"));
god_list=god_list->add(new Link("Hades"));
god_list=god_list->first();
print_all(god_list);
cout<<endl;
keep_window_open();
}
示例12: editfile
void editfile (list_ref list, char *filename) {
char stdinline[1024];
int stdincount = 0;
for(;; ++stdincount) {
printf ("%s: ", Exec_Name);
char *linepos = fgets (stdinline, sizeof stdinline, stdin);
if (linepos == NULL) break;
if (want_echo) printf ("%s", stdinline);
linepos = strchr (stdinline, '\n');
if (linepos == NULL || stdinline[0] == '\0') {
badline (stdincount, stdinline);
}else {
*linepos = '\0';
switch (stdinline[0]) {
case '$': setmove_list(list, MOVE_LAST, stdinline); break;
case '*': print_all(list, stdinline); break;
case '.': viewcurr_list(list, stdinline); break;
case '0': setmove_list(list, MOVE_HEAD, stdinline); break;
case '<': setmove_list(list, MOVE_PREV, stdinline); break;
case '>': setmove_list(list, MOVE_NEXT, stdinline); break;
case '@': debugdump_list (list, stdinline); break;
case 'a': insert_line_after (list, stdinline+1); break;
case 'd': delete_list(list, stdinline); break;
case 'i': insert_line_before(list, stdinline+1); break;
case 'r': insertfile(list, stdinline+1); break;
case 'w': writefile (list, stdinline+1, filename); break;
default : badline (stdincount, stdinline);
}
}
}
printf("%s\n", "^D");
}
示例13: check_count_free_list
/**
* check_count_free_list -Check for count of free blocks, iterating over blocks
* and by going through next pointers
*/
static void check_count_free_list()
{
void *bp;
unsigned int counti = 0;
unsigned int countp = 0;
/*Iterate over list*/
for (bp = heap_listp; GET_SIZE(HDRP(bp)) > 0; bp = NEXT_BLKP(bp)) {
if(!GET_ALLOC(HDRP(bp))) {
counti++;
}
}
/* Moving free list by pointers*/
for (int i = 0; i < NO_OF_LISTS; i++) {
for (bp = GET_SEGI(seg_list,i); (bp!=NULL)
&& (GET_SIZE(HDRP(bp)) > 0);bp = GET_NEXTP(bp)) {
countp++;
}
}
/*If count is not matching, print error, with debug Info*/
if(countp!=counti) {
printf("ERROR: No. of free block mismatch\n");
dbg_printf("free\n");
print_free();
dbg_printf("all\n");
print_all();
}
}
示例14: commandlist
void commandlist(int command){
switch(command){
case 1: case 2: case 3: case 4: case 5:
case 6: case 7: case 8: case 9:
print_run(command);
break;
case 10:
recover_run();
break;
case 11:
print_all();
break;
case 12:
win_stats();
break;
case 13:
best_class();
break;
case 14:
worst_class();
break;
case 15:
played_class();
break;
case 16:
myelo();
break;
case 21: case 22: case 23: case 24: case 25:
case 26: case 27: case 28: case 29:
class_win_stats(command);
break;
}
}
示例15: main
int main(void) {
int arr[2][4]={1,2,3,4,5,6,7,8};
int i;
i=sizeof(arr)/sizeof(*arr);
print_all(arr,i);
return 0;
}