UVa 11462 - Age Sort
2013-04-10 15:16
309 查看
由于输入数据数量很大,但是数据的范围很小,所以用计数排序,代码如下:
View Code
View Code
#include <cstdio> #include <cstring> int main() { int n, x, cnt[101]; while(scanf("%d", &n) != EOF && n) { memset(cnt, 0, sizeof(cnt)); for(int i = 0; i < n; i++) { scanf("%d", &x); cnt[x]++; } int first = 1; for(int i = 1; i <= 100; i++) for(int j = 0; j < cnt[i]; j++) { if(first) first = 0; else printf(" "); printf("%d", i); } printf("\n"); } return 0; }
相关文章推荐
- uva 11462 - Age Sort
- UVA 11462 Age Sort
- UVA 11462(p39)----Age Sort
- uva11462 Age Sort
- UVA11462 Age Sort
- UVa 11462 Age Sort
- uva 11462 Age Sort
- UVA之11462 - Age Sort
- UVa 11462 - Age Sort
- UVa:11462 Age Sort
- Uva - 11462 - Age Sort
- UVA - 11462 Age Sort
- Uva-11462-Age Sort
- UVA - 11462 Age Sort
- UVa 11462 Age Sort
- uva 11462 - Age Sort
- UVA 11462-Age sort
- UVA 11462 Age Sort
- uva11462 - Age Sort
- UVA 11462 Age Sort