CS计算机代考程序代写 #include

#include
#include
#include “refcount.h”

/** Stack Module **/

struct E {
int val;
struct E* next;
};
struct E* head = 0;

struct E* push (int val) {
struct E* e = malloc(sizeof(struct E));
e->val = val;
e->next = head;
head = e;
return e;
}

int pop () {
if (head) {
struct E* oldHead = head;
head = head->next;
return oldHead->val;
} else
return -1;
}

/** Main Module **/

int main (int argc, char** arvc) {
struct E* first;
first = push(1);
pop();
push(2);
pop();
printf(“%d\n”, first->val);
}