---------Node.h--------------
#include<iostream>
using namespace std;
//define the node
/*
    @param
  mark
    @param
  next
**/
class Node{
public:
    float mark;
    Node* next;
    Node(){
        this->mark = 0;
        this->next = NULL;
    };
    Node(float mark,Node*next):mark(0),next(NULL){
        this->mark = mark;
        this->next = next;
    };
    ~Node();
};
Node::~Node(){
    this->mark = 0;
    this->next = NULL;
};
------------------Main.cpp--------------------
#include"Node.h"
#include<iostream>
using namespace std;
Node*head = NULL;
Node*CreateLink(int n);
void InputData(Node*head);
void CalCulateData(Node*head);
void SortData(Node*head);
Node*CreateLink(int n){
    if(n>0){
        while(n>0){
            head = new Node(0,head);
            n--;
        }
    }else{
        cout<<"NULL";
        return NULL;
    }
    return head;
};
void InputData(Node*head){
    for(Node*nPoint = head;nPoint != NULL;nPoint = nPoint->next){
        cout<<"请打分
   :"<<endl;
        cin>>nPoint->mark;
    }
};
void CalCulateData(Node*head){
    float mSum = 0;
    int nMarker = 0;
    float mEVG = 0;
    float bMark = head->mark,sMark = head->mark;
    for(Node*nPoint = head;nPoint != NULL; nPoint = nPoint->next){
        mSum += nPoint->mark;
        if(bMark<nPoint->mark)
            bMark = nPoint->mark;
        if(sMark>nPoint->mark)
            sMark = nPoint->mark;
        nMarker++;
    }
    if(nMarker >0){
        mEVG = (mSum-bMark-sMark)/(nMarker-2);
        cout<<"去掉最高分"<<bMark<<" 去掉最低分 "<<sMark<<" 平均分数为
    :"<<mEVG<<endl;
    }
};
void swap(float n1,float n2){
    n1 = n1 + n2;
    n2 = n1 - n2;
    n1 = n1 - n2;
};
void SortData(Node*head){
    //采用冒泡排序 升序
    int size = 0;
    float marks[50];
    for(Node* tmp = head;tmp != NULL; tmp = tmp->next){
        marks[size] = tmp->mark;
        size++;
    }
    for(int i = 0; i<size-1;i++)
        for(int j = size-1;j>i;j--)
            if(marks[j]<marks[j-1])
                swap(marks[j],marks[j-1]);
    for(int m = 0;m<size;m++)
        cout<<marks[m]<<"->";
    cout<<endl;
};
void main(){
    cout<<"请输入评为个数:"<<endl;
    int nMar = 0;
    cin>>nMar;
    CreateLink(nMar);
    InputData(head);
    CalCulateData(head);
    SortData(head);
};
运行结果截图
	
		
			
        
				
				
					
						图片附件: 游客没有浏览图片的权限,请 
登录 或 
注册