下面是一串c++代码,请问这串代码无法正常运行原因是什么


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
struct Student
{
    char name[20];
    int count;
    char address[50];
}students [3];
int RequestForGrade(Student Student1);
int RequestForAddress(Student Student2);
int FailinExam(Student Student3);
int SortByGrade(Student Student4);
int main()
{
    int choice;
    char buffer[50];
    int n;
    for (n = 0;n < 3;n++)
    {
        cout << "Enter Name:";
        cin.getline(students[2].name, 20);
        cout << "Enter Grade:";
        cin.getline(buffer, 50);
        students[n].count = atoi(buffer);
        cout << "Enter Address:";
        cin.getline(students[2].address, 50);
    }
    cout << "Please Enter The Function You Want:\n" << endl;
    cin >> choice;
    switch (choice)
    {
        case 1:
        {
            SortByGrade;break;
        }
        case 2:
        {
            RequestForGrade;break;
        }
        case 3:
        {
            RequestForAddress;break;
        }
        case 4:
        {
            FailinExam;break;
        }
        default:cout << "Exit the Program" << endl;break;
    }
}
int RequestForGrade(Student Student1)
{
    char Nname[20];
    cout << "Please Enter The Name\n";
    cin >> Nname;
    for (int i = 0;i < 3;i++)
    {
        if (strcmp(Nname, students[i].name) == 0)
        cout << students[i].count;
    }
    return 0;
}
int RequestForAddress(Student Student2)
{
    char Nname[20];
    cout << "Please Enter The Name\n";
    cin >> Nname;
    for (int i = 0;i < 3;i++)
    {
        if (strcmp(Nname, students[i].name) == 0)
            cout << students[i].address;
    }
    return 0;
}
int FailinExam(Student Student3)
{
    int count0 = 0;
    for (int i = 0;i < 3;i++)
    {
        if ((students[i].count) < 60)
            count0++;
    }
    cout << "The number of people who failed the exam is" << count0<<endl;
    return 0;
}
int SortByGrade(Student Student4)
{
    int lh, rh, k, tmp;
    char tmp1[20];
    for (lh = 0;lh < 3;++lh)
    {
        rh = lh;
        for (k = lh;k < 3;++k)
        {
            if (students[k].count < students[rh].count)
                rh = k;
            tmp = students[lh].count;
            students[lh].count = students[rh].count;
            students[rh].count = tmp;
            strcpy(tmp1, students[lh].name);
            strcpy(students[lh].name, students[rh].name);
            strcpy(students[rh].name, tmp1);
        }
    }
    for (lh = 0;lh < 2;++lh)
    {
        cout << students[lh].name;
    }
    return 0;
}

这个程序要求达到的功能:

  1. 从键盘输入名字、成绩、籍贯。
  2. 按“1”,按成绩排序,输出排序后的名字;
    按“2”,查询成绩,输入某人名字,则输出其成绩;
    按“3”,查询籍贯,输入某人名字,则输出其籍贯;
    按“4”,统计不及格人数,并输出;
    按“#”,退出程序。
    ps:本人想先做个小的,方便测试,所以是三个人的元素空间,以后也能方便修改
    谢谢了