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

学号 20182329 2019-2020-1 《数据结构与面向对象程序设计》实验6报告

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

1.实验内容

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

2. 实验过程及结果

  • 经过键盘输入一些整数,创建一个链表,这些数从我学号中依次取出的两位数。打印全部链表元素, 并输出元素的总数,在你的程序中,请用一个liyizhuo来纪录元素的总数。html

  • 从磁盘读取一个文件, 这个文件有两个数字。
    而后从文件中读入数字1, 插入到链表第 5 位,并打印全部数字,和元素的总数。 保留这个链表,继续下面的操做。
    从文件中读入数字2, 插入到链表第 0 位,并打印全部数字,和元素的总数。 保留这个链表,并继续下面的操做。
    从链表中删除刚才的数字1. 并打印全部数字和元素的总数。
    java

  • 使用冒泡排序法或者根据数值大小对链表进行排序。
    android

  • 将实验一、二、3都在Android 里面实现,要修改清单,改变layout布局,java文件不用大改。
    算法

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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:id="@+id/Second"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="9dp"
        android:orientation="vertical">
    </LinearLayout>

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

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

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

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

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

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

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

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

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

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

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

</LinearLayout>

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

  • 问题1:在Android 上实现实验2时,发现本身不能再layout中编写的布局中调用方法Chain6_4数据结构

  • 问题1解决方法:我在编写Second的时候缺乏与之对应的布局。
    布局

  • 问题2:再实验3时,发现缺乏R包,在下载R包后,发现本身编写的方法1又改变了。
  • 问题2解决方法:缺乏menu活动。学习

其余(感悟、思考等)

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

参考资料

相关文章
相关标签/搜索