题目:有一组数据3,5,9,7,4,13,15,0,2,20.已知最大数是20,把数据从小到大排序,而且算法复杂度只能是1

 

代码
public void Sort()
{
    
int[] a =3597413150220 };
    
bool[] b = new bool[21];
    
for (int i = 0; i < a.Length; i++)
    {
        b[a[i]] 
= true;
    }
    
for (int i = 0; i < b.Length; i++)
    {
        
if (b[i])
            Console.WriteLine(i 
+ ",");
    }
    Console.ReadLine();
}

 

有点意思

 

相关文章:

  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
  • 2021-12-05
  • 2021-09-25
  • 2021-09-01
  • 2021-07-02
猜你喜欢
  • 2021-09-11
  • 2022-12-23
  • 2021-05-14
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-04-11
相关资源
相似解决方案