当前位置:   article > 正文

【at89s52单片机的冒泡排序使用指针】2022-4-30

【at89s52单片机的冒泡排序使用指针】2022-4-30

缘由at89s52单片机的冒泡排序-编程语言-CSDN问答

  1. #include "REG52.h"
  2. unsigned char code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07
  3. ,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//0-9A-F
  4. void smxs(unsigned char mz, unsigned char w)
  5. {
  6. unsigned char Xd=0;
  7. P2=255;
  8. P2=255-smgduan[mz];
  9. P3=w;
  10. while(++Xd);
  11. }
  12. void sjh(unsigned char* a, unsigned char* b)
  13. { unsigned char ab = *a; *a = *b; *b = ab; }
  14. void main()
  15. {
  16. unsigned char jz=0,zhi=15,wei=0,sy=0,k=0,sj[]={1,4,7,8,5,2,3,6,9,9,6,8,5,7,4,0};
  17. while(1)
  18. {
  19. smxs(sj[7+wei],128);smxs(sj[6+wei],64);
  20. smxs(sj[5+wei],32);smxs(sj[4+wei],16);
  21. smxs(sj[3+wei],8);smxs(sj[2+wei],4);
  22. smxs(sj[1+wei],2);smxs(sj[0+wei],1);
  23. if(!++sy)
  24. {
  25. if(!wei)wei=8;else wei=0;
  26. if(jz<15)
  27. {
  28. if(sj[jz]>sj[zhi]){sjh(&sj[jz],&sj[zhi]);--zhi;}else --zhi;
  29. if(zhi==jz){zhi=15;++jz;}else;
  30. }
  31. else jz=0;
  32. }
  33. }
  34. }

缘由使用keil编写程序,并且能在proteus上运行_编程语言-CSDN问答

  1. #include "REG52.h"
  2. #include <stdlib.h> //用于随机数生成函数
  3. unsigned char code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07
  4. ,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//0-9A-F
  5. void smxs(unsigned char mz, unsigned char w)
  6. {
  7. unsigned char Xd=0;
  8. P2=255;
  9. P2=255-smgduan[mz];
  10. P3=w;
  11. while(++Xd);
  12. }
  13. void sjh(unsigned char* a, unsigned char* b)
  14. { unsigned char ab = *a; *a = *b; *b = ab; }
  15. void main()
  16. {
  17. unsigned char jz=0,zhi=15,wei=0,sy=0,k=0,sj[16]{},x=16;
  18. while(1)
  19. {
  20. if(x)
  21. {
  22. if(!++sy)if(!++k)
  23. {
  24. --x;
  25. sj[x]=rand()*rand()%10;
  26. }
  27. }
  28. else
  29. {
  30. smxs(sj[7+wei],128);smxs(sj[6+wei],64);
  31. smxs(sj[5+wei],32);smxs(sj[4+wei],16);
  32. smxs(sj[3+wei],8);smxs(sj[2+wei],4);
  33. smxs(sj[1+wei],2);smxs(sj[0+wei],1);
  34. if(!++sy)
  35. {
  36. if(!wei)wei=8;else wei=0;
  37. if(jz<15)
  38. {
  39. if(sj[jz]>sj[zhi]){sjh(&sj[jz],&sj[zhi]);--zhi;}else --zhi;
  40. if(zhi==jz){zhi=15;++jz;}else;
  41. }
  42. else jz=0;
  43. }}
  44. }
  45. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/530653
推荐阅读
相关标签
  

闽ICP备14008679号