1 solutions

  • 0
    @ 2025-11-5 19:09:37

    C++ :

    #include<iostream>
    using namespace std;
    void selectsort(int a[],int n)
    {
    	for (int i=1; i<10; i++)
    	{
    		int k=i;
    		for (int j=i+1; j<=10; j++)
    			if (a[k]<a[j]) k=j;
    		if (k!=i)
    		{ int t=a[k]; a[k]=a[i]; a[i]=t; }
    	}
    }
    bool f(int a[],int n)
    {
    	for (int i=1; i<=n; i++)
    		if (a[i]!=n-i+1) return false;
    	return true;
    }
    int main()
    {
    	int a[11];
    	for (int i=1; i<=10; i++) cin>>a[i];
    	selectsort(a,10);	//选择排序
    	for (int i=1; i<10; i++) cout<<a[i]<<" ";
    	if (f(a,10)) cout<<a[10]<<endl;
    	else cout<<a[10]<<" "<<endl;
    	return 0;
    }
    
    • 1

    Information

    ID
    19202
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By