zoukankan      html  css  js  c++  java
  • UVA-11462 Age Sort

    计数排序

    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    
    int A[100], n;
    int main() {
        while (scanf("%d", &n) && n) {
            memset(A, 0, sizeof(A)); //memset的使用
            for (int i = 0; i < n; ++i) {
                int t;
                scanf("%d", &t);
                A[t]++;
            }
    
            bool first = true;
            for (int i = 0; i < 100; ++i) {
                for (int j = 0; j < A[i]; ++j) {
                    if (first)
                        printf("%d", i), first = false;
                    else
                        printf(" %d", i);
                }
            }
            puts("");  //这个默认带
    ,putchar()不带
        }
    }
  • 相关阅读:
    百度搜索技巧
    phpstorm知识点
    A-Z
    边框
    display
    布局
    盒模型
    浮动
    字体与图标
    pselect 问题
  • 原文地址:https://www.cnblogs.com/wangsong/p/7625680.html
Copyright © 2011-2022 走看看