Xmart Imaging【笔试】

1. 求sizeof

#include <stdio.h>
#include <stdlib.h>

union my
{
        int x;
        int y[5];
        char z;
};
struct you
{
        int a;
        union my b;
        double c;
};
int main()
{

        printf("%d %d\n", sizeof(union my), sizeof(struct you));// 20 32
        return 0;
}

2. 大端小端:大端从低地址向高地址写,直接抄一遍就可以


3. 翻转单链表

struct node
{
        int data;
        struct node * next;
};
struct node * reverse(struct node * head)
{
        struct node *p1, *p2, *p3;
        if (head == NULL || head->next == NULL) return  head;

        p1 = head;
        p2 = p1->next;
        while (p2) {
                p3 = p2->next;
                p2->next = p1;
                p1 = p2;
                p2 = p3;
        }
        head->next = NULL;
        head = p1;
        return head;
}


你可能感兴趣的:(c,struct,null)