Practice Web Page - http://www.cs.tau.ac.il/~efif/courses/Programming_Fall_04
#include <stdio.h> typedef struct item { int value; struct item * next; } Item; int count(Item * head) { int counter = 0; while (head) { counter++; head = head->next; } return counter; } int rcount(Item * head) { if (head == NULL) return 0; return 1 + rcount(head->next); } |
#include <stdio.h> typedef struct item { int value; struct item * next; } Item; Item * meld(Item * head1,Item * head2) { Item * head1_save = head1; if (head1 == NULL) return head2; if (head2 == NULL) return head1; while (head1->next != NULL) head1 = head1->next; head1->next = head2; return head1_save; } |
#include <stdio.h> #define ROW 3 #define COLUMN 4 int main() { int array[ROW][COLUMN]= {{1,2,3,4},{5,6,7,8},{9,10,11,12}}; int i, j; for (i = 0; i < ROW; i++) { for (j = 0; j < COLUMN; j++) printf( "%4d", a[i][j]); printf( "\n" ); } } |
#include <stdio.h> void print_array(int a[][COLUMN], int size) { int i, j; for (i = 0; i < size; i++) { for (j = 0; j < COLUMN; j++) printf("%4d", a[i][j]); printf("\n"); } } |
#include <stdlib.h> #include <stdio.h> |
#include <stdlib.h> #include <stdio.h> |
#include <stdlib.h> #include <stdio.h> |