您的位置:首页 > 其它

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

2014-02-24 19:49 225 查看
直接贴上代码了

#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: