唔西迪西


私信TA

用户名:dotcpp0670030

访问量:148

签 名:

等  级
排  名 6666
经  验 1337
参赛次数 0
文章发表 7
年  龄 0
在职情况 学生
学  校 燕山大学里仁学院
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include<stdio.h>

#include<math.h>

#include<string.h>

void sort(int a[100],int len){

int i,j,max,temp;

    for(i=0;i<len;i++){

max=i;

for(j=i+1;j<len;j++){

if(abs(a[max])<abs(a[j])){

max=j;

}

}

if(max!=i){

temp=a[max];

a[max]=a[i];

a[i]=temp;

}

}

for(i=0;i<len;i++){

printf("%d ",a[i]);

}

}


int main(){

int n,k;

int b[100];

scanf("%d",&n);

    while(n!=0){

    for(k=0;k<n;k++){

    scanf("%d",&b[k]);

}

sort(b,n);

scanf("%d",&n);

}




return 0;

}


 

0.0分

0 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区