博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
uva11462Age Sort
阅读量:6983 次
发布时间:2019-06-27

本文共 461 字,大约阅读时间需要 1 分钟。

题意:题目说输入一些年龄,在1-100之间,然后把它们排序后输出。但是限制条件是输入文件约25MB,内存限制是2MB,不能全都读入后再排序。

分析:数字比较小,可以用计数排序,即用一个数组保存每个年龄出现的个数即可。

View Code
1 #include 
2 #include
3 #include
4 #define DEBUG 5 using namespace std; 6 int main(){ 7 #ifndef DEBUG 8 freopen("in.txt", "r", stdin); 9 #endif10 int n;11 int c[101];12 while(scanf("%d", &n)!=EOF && n){13 memset(c, 0, sizeof(c));14 int i, j;15 for(i=0; i

 

转载地址:http://jpvpl.baihongyu.com/

你可能感兴趣的文章
Linux下安装oracle数据库步骤
查看>>
yum 不小心删除后安装
查看>>
vim 使用
查看>>
为敏感信息设置安全屏障
查看>>
mysql fabric安装使用测试
查看>>
java 对 mongoDB 分组统计操作 以及一些常用操作
查看>>
当你扛不住的时候就读读
查看>>
解决安装rrdtool遇到的一个问题
查看>>
linux启动过程
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
xmlUtil 解析 创建
查看>>
我的友情链接
查看>>
linux 命令(3)echo
查看>>
Nginx基础入门之nginx基础配置项介绍(2)
查看>>
一次详细全面的***报告
查看>>
c# 三种异步编程模型EAP(*)、 APM(*)和 TPL
查看>>
deepin-安装问题:unable to find a medium containing a live file
查看>>
用 Hasor 谈一谈MVC设计模式
查看>>
IE 条件注释
查看>>