我的C++难题,帮助一下

1、编写程序实现在线性表中找出最大的和最小的数据元素,并符合下列要求:
(1)设数据 元素为整数,实现线性表的顺序存储表示。
(2) 从键盘输入10个数据元素,利用顺序表的基本操作建立该表。
(3)利用顺序表的基本操作, 找出表中最大的和最小的数据元素(用于比较的字段为整数)。

2、编写一个程序实现在学生成绩中找出最高分和最低分,并符合下列要求:
(1) 数据元素为学生成绩(含姓名、成绩等字段)。
(2)要求尽可能少地修改第--题的程序来得到此题的新程序,即要符合第一题的所有要求。(这 里用于比较的字段为分数)

运行图及代码如下,如有帮助,请帮忙采纳一下,谢谢:
题1:

img

代码:

#include <iostream>
using namespace std;

struct StNode 
{
    int data;
    struct StNode* next;
};

//创建节点
StNode* CreateNode(int d)
{
    StNode* node = new StNode;
    node->data = d;
    node->next = 0;
    return node;
}
//创建链表
StNode* CreateList()
{
    StNode* head,*p,*t;
    head = 0;
    p = head;
    t = head;
    int data;
    cout << "请输入链表中各节点的值(在一行中输入多个数字,以空格分隔,以回车结束):" <<endl;
    while(1)
    {
        cin >> data;
        t = CreateNode(data);
        if(head ==0)
        {
            head = t;
            p = head;
        }
        else
        {
            p->next = t;
            p = t;
        }

        if (cin.get() == '\n') 
            break;

    }
    return head;
}
//打印链表
void Display(StNode* head)
{
    cout << "打印链表:" << endl;
    while(head)
    {
        cout << head->data << " ";
        head = head->next;
    }
    cout << endl;
}

//查找表中最大的值
void FindMax(StNode* head, StNode* &max,StNode* &min)
{
    StNode* p;
    p = head;
    max = head;
    min = head;
    if(p == 0) return ;
    p= p->next;
    while(p)
    {
        if(p->data > max->data)
        {
            max = p;
        }
        if (p->data < min->data)
        {
            min = p;
        }
        
        p = p->next;
    }
    
}



void Free(StNode* head)
{
    StNode* p = head;
    while(head)
    {
        p = head->next;
        delete head; head = p;
    }
}


int main()
{
    StNode* A=0,*max = 0,*min = 0;
    A = CreateList();
    Display(A);
    FindMax(A,max,min);
    if(max != 0 && min != 0)
        cout << "最大值:" << max->data << ",最小值"<<min->data << endl;
    
    Free(A);
    return 0;
}


题2:

img

代码:

#include <iostream>
#include <string>
using namespace std;

struct StNode 
{
    string name;
    int data;
    struct StNode* next;
};

//创建节点
StNode* CreateNode(string name,int d)
{
    StNode* node = new StNode;
    node->name = name;
    node->data = d;
    node->next = 0;
    return node;
}
//创建链表
StNode* CreateList()
{
    StNode* head,*p,*t;
    string name;
    head = 0;
    p = head;
    t = head;
    int data;
    cout << "请输入链表中各节点的值(在一行中输入以回车结束):" <<endl;
    while(1)
    {
        cin >> name >> data;
        t = CreateNode(name,data);
        if(head ==0)
        {
            head = t;
            p = head;
        }
        else
        {
            p->next = t;
            p = t;
        }

        if (cin.get() == '\n') 
            break;

    }
    return head;
}
//打印链表
void Display(StNode* head)
{
    cout << "打印链表:" << endl;
    while(head)
    {
        cout << head->name <<":" << head->data << endl;
        head = head->next;
    }
    cout << endl;
}

//查找表中最大的值
void FindMax(StNode* head, StNode* &max,StNode* &min)
{
    StNode* p;
    p = head;
    max = head;
    min = head;
    if(p == 0) return ;
    p= p->next;
    while(p)
    {
        if(p->data > max->data)
        {
            max = p;
        }
        if (p->data < min->data)
        {
            min = p;
        }
        
        p = p->next;
    }
    
}



void Free(StNode* head)
{
    StNode* p = head;
    while(head)
    {
        p = head->next;
        delete head; head = p;
    }
}


int main()
{
    StNode* A=0,*max = 0,*min = 0;
    A = CreateList();
    Display(A);
    FindMax(A,max,min);
    if(max != 0 && min != 0)
    {
        cout << "最大成绩:" <<max->name << ":"<< max->data << endl;
        cout << "最小成绩:" <<min->name << ":"<< min->data << endl;
    }
    
    Free(A);
    return 0;
}