算法测试

  1. Ubuntu下支持哪些C语言的排序算法,查找算法?你是怎么得到的?提交截图
  2. 针对下面的数组,调用Linux的 快速排序或二分查找算法。查找算法查自己的学号。
    用随机数函数产生10个 1-1000之间的数存到一个数组int arr[11]中, arr[10] = 你学号的后三位。
    查询截图:

代码:

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
cmp(const void *p1,const void *p2)
{
return *(int*)p1-*(int*)p2;
}
int main(){
srand((unsigned)time(NULL));
int a[11],i;
for(i=0;i<10;i++)
{
a[i]=rand()%1000+1;
printf("%d ",a[i]);
}
printf("%d\n",a[10]=215);
qsort(&a[0],11,sizeof(a[0]),cmp);
for(i=0;i<11;i++)
printf("%d ",a[i]);
printf("\n");
}

本文作者:李业达

本文链接:https://www.cnblogs.com/Werido-/p/15682465.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   李业达  阅读(237)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
  1. 1 世界末日 Jay
  2. 2 花海 Jay
  3. 3 晴天 Jay
  4. 4 爱在西元前 Jay
花海 - Jay
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.