2 solutions

  • 2
    @ 2024-12-29 14:36:57
    #include<bits/stdc++.h>
    using namespace std;
    const int N=25,M=1010;
    int a[N];
    int cnt[M];
    int main()
    {
    	int n;
    	cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		int x;
    		cin>>x;
    		cnt[x]++;
    	}
    	int i=1;
    	for(int j=0;j<M;j++)
    	{
    		while(cnt[j]>0)
    		{
    			a[i++]=j;
    			cnt[j]--;
    		}
    	}
    	for(int i=1;i<=n;i++)
    	{
    		cout<<a[i]<<" ";
    	}
    	return 0;
    }
    • 0
      @ 2026-7-30 20:31:48
      #include <bits/stdc++.h>
      using namespace std;
      const int N=25,M=1010;
      int a[N];
      int cnt[M];
      int main()
      {
      	int n;
      	cin>>n;
      	for(int i=1;i<=n;i++)
      	{
      		int x;
      		cin>>x;
      		cnt[x]++;
      	}
      	int i=1;
      	for(int j=0;j<M;j++)
      	{
      		while(cnt[j]>0)
      		{
      			a[i++]=j;
      			cnt[j]--;
      		}
      	}
      	for(int i=1;i<=n;i++)
      	{
      		cout<<a[i]<<" ";
      	}
      	return 0;
      }
      • 1

      Information

      ID
      115
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      76
      Accepted
      39
      Uploaded By