[查找最大最小]ZOJ 2970 Faster, Higher, Stronger

来源:互联网 发布:ashley家具 知乎 编辑:程序博客网 时间:2024/06/06 17:50

直接贴上代码了

#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){    int cas, p, temp, x = -0x3f3f3f3f, xx = 0x3f3f3f3f;    char s[20];    scanf("%d", &cas);    while(cas -- )    {        x = -0x3f3f3f3f, xx = 0x3f3f3f3f;        scanf("%s", s);        scanf("%d", &p);        if(strcmp(s, "Faster") == 0)        {            while(p --)            {                scanf("%d", &temp);                if(temp < xx) xx = temp;            }            printf("%d\n", xx);        }        else        {            while(p --)            {                scanf("%d", &temp);                if(temp > x) x = temp;            }            printf("%d\n", x);        }    }    return 0;}


0 0
原创粉丝点击