0001、选择排序法

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <time.h>
 4 #define N 20
 5 
 6 
 7 void main()
 8 {
 9     time_t ts;
10     srand((unsigned int)time(&ts));
11 
12     int a[N] = { 0 };
13     
14     for (int i = 0; i < N; i++)
15     {
16         printf("%4d", a[i] = rand() % 300);
17     }
18 
19     int intmax = 0;                选择法找极值(极大值和极小值)
20     for (int i = 0; i < N; i++)
21     {
22         if (intmax < a[i])
23             intmax = a[i];
24     }
25     printf("\nintmax=%d \n", intmax);    // intmax=261 
26 
27     
28     system("pause");
29 }
选择法查找极值

相关文章:

  • 2021-12-29
  • 2021-09-20
  • 2021-12-06
  • 2021-08-01
  • 2021-05-31
  • 2021-07-19
  • 2022-12-23
  • 2021-12-13
猜你喜欢
  • 2021-04-21
  • 2021-10-28
  • 2021-07-14
  • 2021-10-28
相关资源
相似解决方案