课程名称:《程序设计与数据结构》 学生班级:1723班 学生姓名:唐才铭 学生学号:20172319 实验教师:王志强老师 课程助教:张师瑜学姐、张之睿学长 实验时间:2018年09月30日——2018年10月08日 必修/选修:必修
返回目录html
返回目录前端
返回目录java
public void add(int number){ Linked_list_node Node = new Linked_list_node(number); if (this.head==null){ this.head = Node; } else { this.head.addLinked_list_node(Node); } }
System.out.println("实验的第一部分:"); System.out.print("Enter some integers and create a linked list : "); Scanner scanner = new Scanner(System.in); String input = scanner.nextLine(); String[] strings = input.split(" "); Stack<String> Break_up = new Stack<String>(); for (int i = strings.length; i > 0 ; i--){ Break_up.push(strings[i-1]); } System.out.print("The contents of the stack are : "); System.out.println(Break_up); Linked_list linked_list = new Linked_list(); linked_list.add(0); while (!Break_up.empty()) { int tempelement = Integer.parseInt(Break_up.pop()); linked_list.add(tempelement); } int ntangcaiming = 0; ntangcaiming = linked_list.getCount(); System.out.print("The contents of the queue are : "); System.out.println(linked_list); System.out.print("The number of linked elements is : "); System.out.println(ntangcaiming);
运行结果截图:
node
为了更好地实现需求,咱们在链表前端放入了一个取值为0的节点linked_list.add(0);
,以便于在任何地方都能实现插入删除,而打印时将其隐藏。git
public void insert(int index,Linked_list_node node){ if(index < 1||index > getCount() + 1){ System.out.println("Wrong position, cannot insert"); return; } int length = 1; Linked_list_node temp = head; while(head.next != null) { if(index == length++){ node.next = temp.next; temp.next = node; return; } temp = temp.next; } } public void delete(int index){ if(index < 1 || index > getCount()){ System.out.println("Wrong position, cannot be deleted"); return; } int length=1; Linked_list_node temp = head; while(temp.next != null){ if(index == length++){ temp.next = temp.next.next; return; } temp = temp.next; } }
System.out.println("实验的第二部分:"); try { File file = new File("D:\\huawei\\Javawindows文件","EXP1-First semester of sophomore.txt"); InputStreamReader reader = new InputStreamReader(new FileInputStream(file)); BufferedReader bufferedReader = new BufferedReader(reader); int[] file_word_temp = new int[2]; String[] file_word = bufferedReader.readLine().split(" "); file_word_temp[0] = Integer.parseInt(file_word[0]); file_word_temp[1] = Integer.parseInt(file_word[1]); Linked_list_node Node_insert1 = new Linked_list_node(file_word_temp[0]); Linked_list_node Node_insert2 = new Linked_list_node(file_word_temp[1]); linked_list.insert(5,Node_insert1); System.out.print("The list after inserting 1 at the fifth position is : "); System.out.println(linked_list); System.out.print("The number of linked elements is : "); ntangcaiming = linked_list.getCount(); System.out.println(ntangcaiming); linked_list.insert(1,Node_insert2); System.out.print("The list after inserting 2 at the first position is : "); System.out.println(linked_list); ntangcaiming = linked_list.getCount(); System.out.print("The number of linked elements is : "); System.out.println(ntangcaiming); System.out.print("The list after deleting the inserted number 1 is : "); linked_list.delete(6); System.out.println(linked_list); ntangcaiming = linked_list.getCount(); System.out.print("The number of linked elements is : "); System.out.println(ntangcaiming);
运行结果截图:
windows
线性结构之链表(2)数组
冒泡代码实现以下(有删减):服务器
public void Bubble_sort(Linked_list_node Head,Linked_list linked_list){ Linked_list_node temp = null, tail = null; temp = head; int count=1; while(temp.next != tail){ while(temp.next != tail){ if(temp.number > temp.next.number){ int temp_number = temp.number; temp.number = temp.next.number; temp.next.number = temp_number; System.out.print("The list sorted by the "+ count + " truly bubbling sort is : "); System.out.println(linked_list); System.out.print("The number of linked elements is : " + linked_list.getCount() + "\n" ); count++; } temp = temp.next; } tail = temp; temp = head; } }
System.out.println("实验的第三部分:"); System.out.println("Print only the rounds that have implemented the element exchange:"); linked_list.Bubble_sort(linked_list.head,linked_list); } catch (IOException E){ System.out.println("错误,指定路径不存在"); }
运行结果截图(仅仅展现部分截图):
网络
本次提交点相关代码以下:数据结构
System.out.println("实验的第一部分:"); System.out.print("Enter some integers and create a linked list:"); Scanner scanner = new Scanner(System.in); String input = scanner.nextLine(); int ntangcaiming = 0 ; String[] temp_MyArray = input.split(" "); Array MyArray = new Array(temp_MyArray); System.out.print("The elements in the array are: "); System.out.println(MyArray); System.out.print("The number of elements in the array is: "); ntangcaiming = MyArray.size(); System.out.println(ntangcaiming); System.out.println("实验的第二部分:"); try { File file = new File("D:\\huawei\\Javawindows文件","EXP1-First semester of sophomore.txt"); InputStreamReader reader = new InputStreamReader(new FileInputStream(file)); BufferedReader bufferedReader = new BufferedReader(reader); int[] file_word_temp = new int[2]; String[] file_word = bufferedReader.readLine().split(" "); file_word_temp[0] = Integer.parseInt(file_word[0]); file_word_temp[1] = Integer.parseInt(file_word[1]); System.out.print("The array after 1 is inserted in position 5 is : "); Array MyArray1 = new Array(MyArray.Array_Insert(4, String.valueOf(file_word_temp[0]))) ; System.out.println(MyArray1); System.out.print("The number of elements in the array is: "); ntangcaiming = MyArray1.size(); System.out.println(ntangcaiming); System.out.print("The list after inserting 2 at the first position is : "); Array MyArray2 = new Array(MyArray1.Array_Insert(0, String.valueOf(file_word_temp[1]))); System.out.println(MyArray2); System.out.print("The number of elements in the array is: "); ntangcaiming = MyArray2.size(); System.out.println(ntangcaiming); System.out.print("The array after deleting the inserted number 1 is : "); Array MyArray3 = new Array(MyArray2.Array_Delete(5)); System.out.println(MyArray3); System.out.print("The number of elements in the array is: "); ntangcaiming = MyArray3.size(); System.out.println(ntangcaiming);
public String Array_Selection_sort() { int[] temp_MyArray = new int[MyArray.length]; for (int i = 0 ; i < MyArray.length; i ++){ temp_MyArray[i] = Integer.parseInt(MyArray[i]); } String result = ""; for (int i = 0; i < temp_MyArray.length - 1 ; i++){ for (int j = i + 1;j < temp_MyArray.length; j++ ){ if (temp_MyArray[i]<temp_MyArray[j]){ int temp = temp_MyArray[i]; temp_MyArray[i] = temp_MyArray[j]; temp_MyArray[j] = temp; String every = ""; for (int data : temp_MyArray){ every += data + " "; } result += "The list sorted by the SelectSorting is : " + every + "\n" + "The number of elements in the array is: :" + MyArray.length + "\n"; } } } return result; }
System.out.println("实验的第三部分:"); System.out.print(MyArray3.Array_Selection_sort());
解决:起初,在网络上找了个教程(张昊然同窗也发过,但没注意看......),按着教程走,结果:
而后针对他们疯狂地找解决方法例如:git pull origin master --allow-unrelated-histories
但依旧无效,这鬼东西整了我一个星期,最后,张昊然同窗说多是建立的项目的缘由,而后删了项目重建,
语言依旧是Android,其余两个无所谓,但别勾选使用remade初始化项目,最终获得了:
然而它并不能简单地经过右键删除:
经过了解知道:这是一种对于APP的保护机制,要想删除,只能经过:
然而,这仅仅是删除在Android studio上的,要想完全删除,还需去相应文件存储的硬盘里删掉相应文件。
Intellj IDEA 简易教程
Android开发简易教程
Android studio项目上传至oschina(码云)教程