You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

data_struct_test.cpp 3.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. ███████╗██████╗ ██████╗ ███████╗ ███████╗███╗ ██╗ ██████╗ ██╗███╗ ██╗███████╗
  3. ██╔════╝██╔══██╗██╔════╝ ██╔════╝ ██╔════╝████╗ ██║██╔════╝ ██║████╗ ██║██╔════╝
  4. █████╗ ██║ ██║██║ ███╗█████╗ █████╗ ██╔██╗ ██║██║ ███╗██║██╔██╗ ██║█████╗
  5. ██╔══╝ ██║ ██║██║ ██║██╔══╝ ██╔══╝ ██║╚██╗██║██║ ██║██║██║╚██╗██║██╔══╝
  6. ███████╗██████╔╝╚██████╔╝███████╗ ███████╗██║ ╚████║╚██████╔╝██║██║ ╚████║███████╗
  7. ╚══════╝╚═════╝ ╚═════╝ ╚══════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝
  8. Author:Edge
  9. Web:likedge.top
  10. Date:20201213
  11. */
  12. #include<iostream>
  13. #include<ctime>
  14. #include<string>
  15. #include <time.h>
  16. #include <math.h>
  17. #include <fstream>
  18. #include"./autodiff/node.h"
  19. #include"./matrix/matrix_def.h"
  20. #include"./matrix/matrix_pro.h"
  21. #include"./welcome/score_wel.cpp"
  22. #include"./logistic/logistic_def.h"
  23. #include"./file_pro/data_read.h"
  24. #include"./grad_edge/matrix_grad.h"
  25. #include"./data_struct/data_struct_pro.h"
  26. #include"./data_struct/data_struct_pro.c"
  27. using namespace std;
  28. int a[101],n;//定义全局变量,这两个变量需要在子函数中使用
  29. int i,j,t;
  30. //quick_sort
  31. void quicksort(int left,int right)
  32. {
  33. int i,j,t,temp;
  34. if(left>right)
  35. return;
  36. temp=a[left]; //temp中存的就是基准数
  37. i=left;
  38. j=right;
  39. while(i!=j)
  40. {
  41. //顺序很重要,要先从右边开始找
  42. while(a[j]>=temp && i<j)
  43. j--;
  44. //再找右边的
  45. while(a[i]<=temp && i<j)
  46. i++;
  47. //交换两个数在数组中的位置
  48. if(i<j)
  49. {
  50. t=a[i];
  51. a[i]=a[j];
  52. a[j]=t;
  53. }
  54. }
  55. //最终将基准数归位
  56. a[left]=a[i];
  57. a[i]=temp;
  58. quicksort(left,i-1);//继续处理左边的,这里是一个递归的过程
  59. quicksort(i+1,right);//继续处理右边的 ,这里是一个递归的过程
  60. }
  61. int main()
  62. {
  63. // Node_link_list c(3);
  64. int len=10;
  65. link_list list1 = link_list(5);
  66. //遍历
  67. list_ergodic(list1);
  68. cout<<"----------insert element------"<<endl;
  69. insert_element_ll(1,list1,5);
  70. list_ergodic(list1);
  71. cout<<"-------delement_ll---------"<<endl;
  72. dele_element_ll(119,list1);
  73. list_ergodic(list1);
  74. cout<<"----------------end insert------------------"<<endl;
  75. insert_end_ll(9,list1);
  76. list_ergodic(list1);
  77. // return 1;
  78. //quicksort
  79. //读入数据
  80. scanf("%d",&n);
  81. for(i=1;i<=n;i++)
  82. scanf("%d",&a[i]);
  83. quicksort(1,n); //快速排序调用
  84. //输出排序后的结果
  85. for(i=1;i<=n;i++)
  86. printf("%d ",a[i]);
  87. getchar();getchar();
  88. return 0;
  89. }

Edge : 一个开源的科学计算引擎