📄 main.java
字号:
/*
* Main.java
*
* Created on 2008年3月27日, 下午9:36
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package javaapplication27;
import javax.swing.*;
import javax.swing.plaf.metal.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.table.*;
/**
*
* @author 19selong
*/
class Student{
Student next, prev;
String id;
String name;
String age;
String sex;
String grade;
String gclass;
}
//****************************************************************************************method sort
class SortID{//method SortStudentID
public Student SortStudentID(Student s,int length){
Student one=s;
Student two=s.next;
Student comp;
for(int i=0;i<length-1;i++){//"maopao" sort method
if(Integer.parseInt(one.id)<Integer.parseInt(two.id)){//the compare of one node and two node
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
s=two;
two=one.next;
}
else{
s=one;
one=one.next;
two=one.next;
}
for(int j=1;j<length-1-i;j++){// the compare of rest node
if(Integer.parseInt(one.id)<Integer.parseInt(two.id)) {
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
two=one.next;
}
else {
one=two;
two=two.next;
}
}
one=s;//makesure one is always pointing the first node
two=s.next;
}
return s;
}
}
class UnSortID{//method SortStudentID
public Student SortStudentID(Student s,int length){
Student one=s;
Student two=s.next;
Student comp;
for(int i=0;i<length-1;i++){//"maopao" sort method
if(Integer.parseInt(one.id)>Integer.parseInt(two.id)){//the compare of one node and two node
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
s=two;
two=one.next;
}
else{
s=one;
one=one.next;
two=one.next;
}
for(int j=1;j<length-1-i;j++){// the compare of rest node
if(Integer.parseInt(one.id)>Integer.parseInt(two.id)) {
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
two=one.next;
}
else {
one=two;
two=two.next;
}
}
one=s;//makesure one is always pointing the first node
two=s.next;
}
return s;
}
}
class SortName{
public Student SortStudentName(Student s,int length){
Student one=s;
Student two=s.next;
Student comp;
for(int i=0;i<length-1;i++){
if(one.name.compareToIgnoreCase(two.name)<0){
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
s=two;
two=one.next;
}
else{
s=one;
one=one.next;
two=one.next;
}
for(int j=1;j<length-1-i;j++){
if(one.name.compareToIgnoreCase(two.name)<0) {
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
two=one.next;
}
else {
one=two;
two=two.next;
}
}
one=s;
two=s.next;
}
return s;
}
}
class UnSortName{
public Student SortStudentName(Student s,int length){
Student one=s;
Student two=s.next;
Student comp;
for(int i=0;i<length-1;i++){
if(one.name.compareToIgnoreCase(two.name)>0){
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
s=two;
two=one.next;
}
else{
s=one;
one=one.next;
two=one.next;
}
for(int j=1;j<length-1-i;j++){
if(one.name.compareToIgnoreCase(two.name)>0) {
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
two=one.next;
}
else {
one=two;
two=two.next;
}
}
one=s;
two=s.next;
}
return s;
}
}
class SortSex{
public Student SortStudentSex(Student s,int length){
Student one=s;
Student two=s.next;
Student comp;
for(int i=0;i<length-1;i++){
if(one.sex.compareToIgnoreCase(two.sex)<0){
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
s=two;
two=one.next;
}
else{
s=one;
one=one.next;
two=one.next;
}
for(int j=1;j<length-1-i;j++){
if(one.sex.compareToIgnoreCase(two.sex)<0) {
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
two=one.next;
}
else {
one=two;
two=two.next;
}
}
one=s;
two=s.next;
}
return s;
}
}
class SortAge{//method SortStudentAge
public Student SortStudentAge(Student s,int length){
Student one=s;
Student two=s.next;
Student comp;
for(int i=0;i<length-1;i++){//"maopao" sort method
if(Integer.parseInt(one.age)<Integer.parseInt(two.age)){//the compare of one node and two node
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
s=two;
two=one.next;
}
else{
s=one;
one=one.next;
two=one.next;
}
for(int j=1;j<length-1-i;j++){// the compare of rest node
if(Integer.parseInt(one.age)<Integer.parseInt(two.age)) {
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
two=one.next;
}
else {
one=two;
two=two.next;
}
}
one=s;//makesure one is always pointing the first node
two=s.next;
}
return s;
}
}
class SortGrade{
public Student SortStudentGrade(Student s,int length){
Student one=s;
Student two=s.next;
Student comp;
for(int i=0;i<length-1;i++){
if(one.grade.compareToIgnoreCase(two.grade)<0){
one.prev.next=two;
two.next.prev=one;
comp=one.prev;
one.prev=two;
one.next=two.next;
two.prev=comp;
two.next=one;
s=two;
two=one.next;
}
else{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -