[查找最大最小]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;
}
#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;
}
相关文章推荐
- 动态下载苹果提供的多种中文字体
- 网线水晶头接法图解
- hdu2149Public Sale (巴什博弈)
- php设置和获取变量类型
- Openipmp安装 linux
- Git 系列之一:版本控制的概念、分布式、Git 简介及其工作流程
- Java Exception: 六种异常处理的陋习
- 程序员必看的十大电影
- 测试网口故障的方法-回环水晶头及实验方法
- Wp8—LongListSelector控件使用
- System timers granularity
- Git 系列之一:版本控制的概念、分布式、Git 简介及其工作流程
- 存储故障导致ESXI主机变慢
- 字节与字符,字符与字符集
- 使用Guid值作为数据库行标识
- Ubuntu下安装和配置Apache2
- 《马哥出品高薪linux运维教程》wingkeung学习笔记-linux基础入门课程5
- Visual Studio 2010 搭建OpenCV2.48
- 软件工程师的情书
- 第一周项目2-体重情况