ajsdashjbd


私信TA

用户名:lqbgsdy

访问量:13295

签 名:

等  级
排  名 969
经  验 3270
参赛次数 12
文章发表 6
年  龄 0
在职情况 学生
学  校 ccgc
专  业

  自我简介:

 

0.0分

21 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

有一个东西叫做sort
2024-03-22 21:31:29
怎么不对呢
#include<iostream>
#include<iomanip>
using namespace std;
int findmaxpos(int arr[],int n) {
	int max=arr[0];
	int pos=0;
	for(int i=1; i<n; i++) {
		if(arr[i]>max) {
			max=arr[n];
			pos=i;
		}
	}
	return pos;
}
void selectionSort(int arr[],int n) {
	while(n>1) {
		int pos=findmaxpos(arr,n);
		int temp=arr[n-1];
		arr[n-1]=arr[pos];
		arr[pos]=temp;
		n--;
	}
}

int main() {
	int a[10];
	for(int i=0; i<10; i++)
		cin>>a[i];
	selectionSort(a,10);
	for(int i=0; i<10; i++)
		cout<<a[i]<<endl;

}
2023-01-08 15:33:49
  • «
  • 1
  • »