1 Star 0 Fork 0

柳星宇 / JAVA project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
shiyan6Test2.java 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
柳星宇 提交于 2021-11-03 09:12 . 实验六
import java.io.*;
import java.util.Scanner;
public class shiyan6Test2 {
public static void main(String[] args) throws IOException
{
Link link = new Link();
Scanner scan = new Scanner(System.in);
int n,a,b;
File file = new File("test.txt");
if (!file.exists()){
file.createNewFile();
}
OutputStream outputStream1 = new FileOutputStream(file);
byte[] test1 = {'5','9'};
outputStream1.write(test1);
InputStream inputStream1 = new FileInputStream(file);
a = (char) inputStream1.read()-48;
b = (char) inputStream1.read()-48;
System.out.print("输入数字,输入0结束:");
for (;;)
{
n = scan.nextInt();
if (n == 0)
{
break;
}
link.AddNode(n);
}
System.out.println("输入完毕");
System.out.print("输入的链表为");
link.Print();
System.out.println("此时链表中的元素个数为"+link.Length());
link.InsertNode(6,a);
System.out.print("将数据a添加进链表中");
link.Print();
System.out.println("此时链表中的元素个数为"+link.Length());
link.InsertNode(4,b);
System.out.print("将数据b添加进链表中");
link.Print();
System.out.println("此时链表中的元素个数为"+link.Length());
System.out.print("删除数据a");
link.DeleteNode(2);
link.Print();
System.out.println("此时链表中的元素个数为"+link.Length());
link.Sort();
System.out.print("使用选择排序对链表中的元素进行排序");
link.Print();
}
}
1
https://gitee.com/lxy20010524/java-project.git
git@gitee.com:lxy20010524/java-project.git
lxy20010524
java-project
JAVA project
master

搜索帮助