站外题,求大佬帮忙
  • 板块题目总版
  • 楼主DYF2024
  • 当前回复2
  • 已保存回复2
  • 发布时间2025/2/4 21:02
  • 上次更新2025/2/5 10:41:19
查看原帖
站外题,求大佬帮忙
1584005
DYF2024楼主2025/2/4 21:02

目前已经确定是输入的问题,不知道怎么改。 代码:

#include <bits/stdc++.h>
using namespace std;
int people,temp,j_1,j_2,tempy,tempm,tempd,tel[200005],y[200005],m[200005],d[200005],day[1240];
string name[200005],sex[200005];
int main()
{
    cin>>people;
    for(int i=0;i<people;i++) {
        cin>>name[i]>>sex[i]>>tel[i];
        scanf("%d-%d-%d",&tempy,&tempm,&tempd);
        y[i]=tempy;
        m[i]=tempm;
        d[i]=tempd;
    }
    for(int i=0;i<people;i++){
        temp=m[i]*100+d[i];
        day[temp]++;
        if(day[temp]==2){
            j_1=i;
            for(int k=0;k<i;k++){
                if(m[k]*100+d[k]==temp){
                    j_2=k;
                }
            }
            cout<<j_2+1<<" "<<name[j_2]<<" "<<sex[j_2]<<" "<<tel[j_2]<<" "<<y[j_2]<<"-"<<m[j_2]<<"-"<<d[j_2]<<"\n";
            cout<<j_1+1<<" "<<name[j_1]<<" "<<sex[j_1]<<" "<<tel[j_1]<<" "<<y[j_1]<<"-"<<m[j_1]<<"-"<<d[j_1];
            return 0;
        }
    }
    cout<<-1;
    return 0;
}

题目链接:https://boyacoding.cn/p/A0093

2025/2/4 21:02
加载中...