8 条题解

  • 0
    @ 2022-7-12 10:40:01

    #include

    #include

    #include

    #include <string.h>

    #include

    using namespace std;

    #define LL long long

    const int N = 1e6 + 10;

    const int INF = 0x3f3f3f3f;

    int a[N];

    int main()

    {

    int n;
    
    cin >> n;
    

    // for(int i = 1; i <= n; i++)

    // {

    // cin >> a[i];

    // }

    // for(int i= 1; i <= n-1; i++)

    // {

    // for(int j = 1; j <= n-i; j++)

    /// {

    // if(a[j] > a[j+1])

    // {

    // int t = a[j];

    // a[j] = a[j+1];

    // a[j+1] = t;

    // }

    // }

    // }

    for(int i = 1; i <= n; i++)
    
    {
    
    	int id = i;
    
    	for(int j  =i+1; j<= n; j++)
    
    	{
    
    		if(a[id] > a[j])
    
    		id = j;
    
    	}
    
    	if(id != i)
    
    	{
    
    		int t = a[id];
    
    		a[id] = a[i];
    
    		a[i] = t;
    
    	}
    
    }
    
    for(int i = 1; i<=n; i++)
    
    	cout << a[i]<<" ";
    

    }

    信息

    ID
    1026
    时间
    1000ms
    内存
    32MiB
    难度
    6
    标签
    递交数
    535
    已通过
    171
    上传者