当前位置:网站首页>PAT1006

PAT1006

2022-08-09 11:09:00 AlanLiu6

使用了一些常用的函数,手感生疏啊

https://pintia.cn/problem-sets/994805342720868352/problems/994805514284679168

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

int main()
{
    int m;
    string inID;
    string outID;
    scanf("%d",&m);
    char start[10],ending[10];

    for(int i = 0;i < m;i++)
    {
        string t;
        cin >> t;
        char str[2][10];
        scanf("%s %s",str[0],str[1]);

       // cout << str[0] << endl << str[1] << endl;

       if(i == 0)// 第一个
       {
           inID = t;
           outID = t;
           strcpy(start,str[0]);
           strcpy(ending,str[1]);
           continue;
       }

        if(strcmp(str[0],start) <= 0)
        {
            strcpy(start,str[0]);
            inID=t;
        }
        if(strcmp(str[1],ending) >= 0)
        {
            strcpy(ending,str[1]);
            outID=t;
        }


    }

    cout << inID << " " << outID << endl;

    return 0;
}

原网站

版权声明
本文为[AlanLiu6]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Alen666/article/details/97621486