Behold the following C program:
|
--- |
When we run this program, the first two lines of output are:
What are the remaining lines of output?
|
|
|
||
|
|
||
|
|
A goddess on the mountain top Is burning like a silver flame The summit of beauty and love And Venus is her name |
main() { IS is; Dllist d, tmp; int i; d = new_dllist(); i = 0; is = new_inputstruct(NULL); while (get_line(is) >= 0) { if (i % 2 == 0) { dll_append(d, new_jval_s(strdup(is->fields[0]))); } else { dll_prepend(d, new_jval_s(strdup(is->fields[is->NF-1]))); } i++; } dll_traverse(tmp, d) { printf("%s\n", tmp->val.s); } } |
main() { Queue q; Stack s; Jval v; IS is; int i; q = new_queue(); s = new_stack(); i = 0; is = new_inputstruct(NULL); while (get_line(is) >= 0) { if (i % 2 == 0) { queue_enqueue(q, new_jval_s(strdup(is->fields[0]))); } else { stack_push(s, new_jval_s(strdup(is->fields[0]))); } i++; } while (!queue_empty(q)) { v = queue_dequeue(q); printf("%s\n", v.s); } while (!stack_empty(s)) { v = stack_pop(s); printf("%s\n", v.s); } } |
main() { int i; IS is; char *x, *y; i = 0; is = new_inputstruct(NULL); while (get_line(is) >= 0) { x = strchr(is->text1, 'o'); if (x == NULL) x = is->text1; y = strchr(is->text1, 's'); if (y == NULL) y = is->text1; printf("%d\n", y - x); } } |
|
--- |
|