#include <stdio.h>
void foo
(int** a
) {
int i;
for (i =
0; i <
3; i++
)
(*a
)++;
}
void bar
(int* a
) {
foo
(&a
);
printf("%d\n", *
(a +
1));
}
int main
() {
int data
[4] =
{ 1,
2,
3,
4 };
bar
(data
);
return 0;
}
#include <stdio.h>
void bar
(int n
) {
if (n <=
2) return;
if (n %
2 ==
0)
printf("B");
else {
printf("A");
}
bar
(n /
2 +
((n +
1 *
2 %
3 ==
0) ?
1 :
0));
}
int main
() {
bar
(24);
return 0;
}
#include <stdio.h>
void swappiness
(int a,
int b,
int * c,
int * d
) {
int * e = c;
c = d;
d = e;
int f = a;
a = b;
b = f;
f = a;
a = b;
b = f;
}
int main
() {
int a =
10, b =
20;
swappiness
(a, b, &b, &a
);
printf("%d %d\n", a, b
);
return 0;
}
#include <stdio.h>
void knock_knock
(char * s
) {
while (*s++ !=
'\0')
printf("Bazinga");
}
int main
() {
int data
[5] =
{ -1,
-3,
256,
-4,
0};
knock_knock
((char *
) data
);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main
() {
int i, * data
[10];
for (i =
0; i <
10; i++
)
data
[i
] = malloc
(sizeof(int) *
10);
printf("%ld\n",
(long int) (data +
3) -
(long int) (data +
1));
return 0;
}
#include <stdlib.h>
#include <stdio.h>
typedef struct node_t {
struct node_t * next;
int data;
} node_t;
typedef struct linked_list_t {
node_t * head;
} linked_list_t;
static node_t* new_node() {
node_t *n = malloc(sizeof(node_t));
if (n == NULL) exit(1);
n->next = NULL;
return n;
}
static linked_list_t* new_linked_list() {
linked_list_t *list = malloc(sizeof(linked_list_t));
if (list == NULL) exit(1);
list->head = NULL;
return list;
}
static void append_elem(linked_list_t *list, int x) {
if (list == NULL) exit(1);
if (list->head == NULL) {
list->head = new_node();
list->head->data = x;
} else {
node_t *tail = list->head;
while (tail->next != NULL) tail = tail->next;
tail->next = new_node();
tail->next->data = x;
}
}
void delete_linked_list(linked_list_t *list) {
node_t *n = list->head;
while (n != NULL) {
free(n);
n = n->next;
}
}
int main() {
linked_list_t * l = new_linked_list();
append_elem(l, 666);
append_elem(l, 333);
append_elem(l, 111);
delete_linked_list(l);
return 0;
}
#include <stdio.h>
int main
() {
char b =
1;
while(b <=
127) {
printf("%u\n",
(unsigned int) b
);
b++;
}
return 0;
}
#include <stdio.h>
int main
() {
int a =
39, n =
1, k =
0;
while (a & n
) {
k++;
n *=
2;
}
printf("%d", k
);
return 0;
}