关于#结构体#的问题,如何解决?(语言-c++)

您好,这是我在编程过程中遇到的问题,我的代码有错误,希望您能够帮忙指出,并附上正确的,能通过的代码,谢谢。
【题目描述】一个有180人的大班级中,存在两个人生日相同的概率非常大,现给出每个学生的名字,出生月日。试找出所有生日相同的学生。
【Input】第一行为整数n,表示有n个学生,n ≤ 180。此后每行包含一个字符串和两个整数,分别表示学生的名字(名字第一个字母大写,其余小写,不含空格,且长度小于20)和出生月(1 ≤ m ≤ 12)日(1 ≤ d ≤ 31)。名字、月、日之间用一个空格分隔。
【Output】每组生日相同的学生,输出一行,其中前两个数字表示月和日,后面跟着所有在当天出生的学生的名字,数字、名字之间都用一个空格分隔。对所有的输出,要求按日期从前到后的顺序输出。 对生日相同的名字,按名字从短到长按序输出,长度相同的按字典序输出。如没有生日相同的学生,输出”None”。


#include 
using namespace std;
int num=0;
struct samebirth{
    string name;
    float month;
    float day;
};    
struct samebirth student[200];
int main(){
    int n;//学生的数量
    cin>>n;
    for(int i=0;i>student[n];
    sort(student[1].month.day,student[1+n].month.day);
    if(student[n].month.day==student[n+1].month.day) num++;
    }
    if(num>=2){
        for(int i=0;ielse cout<<"None"<return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;//学生的数量
    cin>>n;

    struct samebirth{
        string name;
        float month;
        float day;
    };    
    struct samebirth student[200];

    for(int i=0;i<n;i++){
        cin>>student[i].name>>student[i].month>>student[i].day;
    }
    sort(student, student + n, [](samebirth a, samebirth b){
        if (a.month == b.month) return a.day < b.day;
        else return a.month < b.month;
    });

    int num = 0;
    for(int i=0;i<n-1;i++){
        if(student[i].month==student[i+1].month&&student[i].day==student[i+1].day) {
            num++;
        }
    }
    if(num>=1){
        for(int i=0;i<n;i++){
            if(i<n-1&&student[i].month==student[i+1].month&&student[i].day==student[i+1].day){
                cout<<student[i].name<<" "<<student[i].month<<" "<<student[i].day<<endl;
            }
            else if(i>0&&student[i].month==student[i-1].month&&student[i].day==student[i-1].day){
                cout<<student[i].name<<" "<<student[i].month<<" "<<student[i].day<<endl;
            }
        }
    }
    else cout<<"None"<<endl;
    return 0;
}

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^