标签:space 默认 blog print pac logs code bool char
计数排序
#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(""); //这个默认带\n,putchar()不带 } }
标签:space 默认 blog print pac logs code bool char
原文地址:http://www.cnblogs.com/wangsong/p/7625680.html