藏书阁 史将 特技
背景 三国演义 PC版
首页 -> 精彩文章 -> 文章
RE:嵌入式作业一排序
作者拉格浪日
标签编程
阅读次数:27
在CODE WARRIOR下通过!
#include
#include
void select(int * src,int number)
{
 __asm{
    SUBS R1,R1,#1
loop: MOV R7,R1
   MOV R4,R0
loop2: LDR R5,[R4]
LDR R6,[R4,#4]!
CMP R5,R6
BLS skip
STR R5,[R4]
STR R6,[R4,#-4]
skip:  SUBS R1,R1,#1
BNE loop2
MOV R1,R7
SUBS R1,R1,#1
BNE loop
//quit:
}
}
int main() {
int i=0;
int num=0;
int *array=NULL;

while(num <= 0) {
printf("please enter the number of elements:\n");
scanf("%d",&num);
if(num > 0) {
break;
}
}

if(NULL == (array = (int *)malloc(num*sizeof(int)))) {
printf("malloc failed!\n");
exit(-1);
}
printf("please enter the elements:\n");
for(i = 0; i printf("\n%d:\t", i);
scanf("%d", array+i);
}
select(array,num);
printf("=========================\nthe result is:\n");
for(i = 0; i printf("%d:\t%d\n", i, *(array+i));
}

return 0;

}


浙ICP备06020153号-1