• 课程:《程序设计与数据结构》
  • 班级: 1823
  • 姓名: 李一卓
  • 学号:20182329
  • 实验教师:王志强
  • 实验日期:2019年10月25日
  • 必修/选修: 必修

1.实验内容

  • 学习使用链表,构建链表,记下元素。
  • 在链的基础上,学会实现节点插入、删除、输出操作;
  • 学会使用链表的排序方法,比如:冒泡法、选择排序法。
  • 学会在Android 上构建活动去实现链。

2. 实验过程及结果

  • 通过键盘输入一些整数,建立一个链表,这些数从我学号中依次取出的两位数。打印所有链表元素, 并输出元素的总数,在你的程序中,请用一个liyizhuo来纪录元素的总数。《数据结构与面向对象程序设计》实验6报告

  • 从磁盘读取一个文件, 这个文件有两个数字。
    然后从文件中读入数字1, 插入到链表第 5 位,并打印所有数字,和元素的总数。 保留这个链表,继续下面的操作。
    从文件中读入数字2, 插入到链表第 0 位,并打印所有数字,和元素的总数。 保留这个链表,并继续下面的操作。
    从链表中删除刚才的数字1. 并打印所有数字和元素的总数。
    《数据结构与面向对象程序设计》实验6报告

  • 使用冒泡排序法或者根据数值大小对链表进行排序。
    《数据结构与面向对象程序设计》实验6报告

  • 将实验1、2、3都在Android 里面实现,要修改清单,改变layout布局,java文件不用大改。
    《数据结构与面向对象程序设计》实验6报告

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:andro
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="MissingDefaultResource">

    <LinearLayout
        android:
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="9dp"
        android:orientation="vertical">
    </LinearLayout>

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

    <TextView
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

</LinearLayout>

《数据结构与面向对象程序设计》实验6报告

3. 实验过程中遇到的问题和解决过程

  • 问题1:在Android 上实现实验2时,发现自己不能再layout中编写的布局中调用方法Chain6_4《数据结构与面向对象程序设计》实验6报告

  • 问题1解决方法:我在编写Second的时候缺少与之对应的布局。
    《数据结构与面向对象程序设计》实验6报告

  • 问题2:再实验3时,发现缺少R包,在下载R包后,发现自己编写的方法1又改变了。

  • 问题2解决方法:缺少menu活动。

其他(感悟、思考等)

在学习链的排序时,发现有很多方法可以用,不是非要冒泡法或选择排序发,哈希法取模循环排序也可以为数字排序,不过排序首先得查找,再决定用交换还是插入排序,当然最简单的线性排序交换也可以,快速排序的交换方法是最快的算法。

参考资料

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
猜你喜欢
  • 2022-02-12
  • 2021-09-20
  • 2021-09-03
  • 2021-11-19
  • 2021-06-18
  • 2021-10-20
  • 2021-10-22
相关资源
相似解决方案