数据结构D2作业

1.

2

.

#include <stdio.h>
#include <string.h>
union Store
{
    char p;
    int a;
};
int main(int argc, const char *argv[])
{
    union Store A;  
     A.a=0x12345678;
    printf("%#X\n",A.a);
    printf("%#X\n",A.p);
    printf("%p\n",&A.p);
    printf("%p\n",&A.p+3);

    char *p1=&A.a;
    printf("%#X\n",*p1);
    printf("%p\n",p1);
    printf("%p\n",p1+3);

    return 0;
}

3

#include<stdio.h>
#include<string.h>
#include"seq.h"
int main(int argc, const char *argv[])
{
    seq_p L=create_seq_list();
    printf("%d\n",seq_empty(L));
    printf("%d\n",seq_full(L));
    return 0;
}
ubuntu@ubuntu:seq_list$ cat seq.c
#include<stdio.h>
#include<string.h>
#include"seq.h"
seq_p create_seq_list()
{
    seq_p L=(seq_p)malloc(sizeof(seq));
    if(L==NULL)
    {
        printf("空间申请失败\n");
        return 0;
    }
    L->len=0;
    bzero(L,sizeof(L->data));
    return L;
}

int seq_empty(seq_p L)
{
    if(L==NULL)
    {
        return -1; 
    }
    return *(L->data)==0?1:0;
}

int seq_full(seq_p L)
{
    if(L==NULL)
    {
        return -1; 
    }
    return *(L->data+MAX-1)!=0?1:0;
}
ubuntu@ubuntu:seq_list$ cat seq.h
#ifndef __SEQ_H__
#define __SEQ_H__
#include <stdlib.h>
#define MAX 7
typedef int datatype;
typedef struct seq_list
{
    datatype data[MAX];
    int len;
}seq,*seq_p;
seq_p create_seq_list();
int seq_empty(seq_p L);
int seq_full(seq_p L);
#endif

相关推荐

  1. [数据结构]串、数组 C++编程作业

    2024-02-22 07:46:01       47 阅读
  2. [数据结构] 栈和队列C++作业

    2024-02-22 07:46:01       42 阅读
  3. [数据结构]C++递归算法作业

    2024-02-22 07:46:01       55 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-22 07:46:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-22 07:46:01       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-22 07:46:01       82 阅读
  4. Python语言-面向对象

    2024-02-22 07:46:01       91 阅读

热门阅读

  1. 事件流 事件委托

    2024-02-22 07:46:01       59 阅读
  2. Vue中v-model的原理

    2024-02-22 07:46:01       46 阅读
  3. docker入门介绍

    2024-02-22 07:46:01       61 阅读
  4. Backend - Docker 离线卸载

    2024-02-22 07:46:01       50 阅读
  5. Vue3利用父子组件实现字典

    2024-02-22 07:46:01       56 阅读
  6. linux系统离线安装docker服务教程

    2024-02-22 07:46:01       57 阅读
  7. 深度学习基础之《TensorFlow框架(5)—会话》

    2024-02-22 07:46:01       56 阅读
  8. select滑动分页请求数据

    2024-02-22 07:46:01       51 阅读
  9. springboot 控制层 aop 日志

    2024-02-22 07:46:01       50 阅读
  10. 深度学习????????

    2024-02-22 07:46:01       53 阅读
  11. BeautifulSoup的使用与入门

    2024-02-22 07:46:01       50 阅读
  12. 计算机科学背后的故事和挑战

    2024-02-22 07:46:01       57 阅读