UVA 11462 年龄排序【快速读入】
了解一下快速读入的代码
inline int readint()
{
char c = getchar();
while(!isdigit(c)) c=getchar();
int x=0;
while(isdigit(c))
{
x=x*10+c-'0';
c=getchar();
}
return x;
}
快速输出
int buf[10];
inline void writeint(int i)
{
int p =0;
if(i==0)p++;
else while(i)
{
buf[p++]=i%10;
i/=10;
}
for(int j=p-1;j>=0;j--)putchar('0'+buf[j]);
}
#include <bits/stdc++.h>
#define cl(a) memset(a,0,sizeof(a))
#define sc(x) scanf("%d",&x)
#define pf(x) printf("%d\n",x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
using namespace std;
const int mod=1e9+7;
typedef long long ll;
const int maxn=2e6+50;
const int inf=0x3f3f3f3f;
typedef pair <int,int> PII;
ll fpow(ll n,ll k,ll p =mod){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%p;n=n*n%p;}return r;}
ll inv(ll n, ll p=mod) {return fpow(n,p-2,p);}
ll fact[maxn];
void init(){fact[0]=1;for(int i=1;i<maxn;i++)fact[i]=fact[i-1]*i%mod;}
ll C(ll n,ll m,ll p){ll r = fact[n]; r = r * inv(fact[m])%p; r = r*inv(fact[n-m])%p;return r;}
inline int readint()
{
char c = getchar();
while(!isdigit(c)) c=getchar();
int x=0;
while(isdigit(c))
{
//cout<<c<<endl;
x=x*10+c-'0';
//cout<<x<<endl;
c=getchar();
}
//cout<<x<<endl;
return x;
}
int buf[10];
inline void writeint(int i)
{
int p =0;
if(i==0)p++;
else while(i)
{
buf[p++]=i%10;
i/=10;
}
for(int j=p-1;j>=0;j--)putchar('0'+buf[j]);
}
int cnt[200];
int a[maxn];
int main()
{
int n;
while(n=readint())
{
// cout<<n<<endl;
cl(cnt);
int f=0;
rep(i,1,n) {int x=readint();cnt[x]++;}
rep(i,1,100)
{
rep(j,1,cnt[i])
if(!f) writeint(i),f=1;
else putchar(' '),writeint(i);
}
puts("");
// n=readint();
}
return 0;
}