2 条题解

  • 0
    @ 2023-2-3 19:43:26
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,a[11],num=0;
        cin >> n;
        for(int i=1;i<=n;i++)
        {
            cin >> a[i];
            if(a[i]==0)
            {
                num++;
            }
        }
        sort(a+1,a+1+n);
        for(int i=1+num;i<=n;i++)
        {
            cout << a[i];
            if(i==1+num)
            {
                for(int i=1;i<=num;i++)
                {
                    cout << 0;
                }
            }
        }
    }
    
    • 0
      @ 2023-1-21 15:58:13
      #include<bits/stdc++.h>
      using namespace std;
      int a[11]; 
      int main()
      {
      	int n, m;
      	cin >>n;
      	for (int i = 0; i < n; i++){
      		cin >> m;
      		a[m]++;//加入0~9下标数组计算个数 
      	}
      	string s;
      	for(int i = 0; i <=9; i++){
      		for(int j = 0; j < a[i]; j++){
      			s += (i + '0');
      		}
      	}
      	if(s[0] == '0')//若首位为0,找到第一个不是0的数,交换 
      	{
      		int i =1;
      		while(s[i] == '0') i++;
      		swap(s[0],s[i]);
      	}
      	cout << s;
      	return 0;
      }
      
      
      
      • 1

      【入门】n个一位数能够组成的最小数

      信息

      ID
      449
      时间
      1000ms
      内存
      32MiB
      难度
      2
      标签
      递交数
      48
      已通过
      30
      上传者