写了一个inst.c文件:
功能是用来进行插入排序。
写了一个shel.c文件:
写了一个主文件inst0.c,用来包括inst.c,shel.c文件:
此时进行编译:gcc -o inst0 inst0.c inst.c shel.c,会报错:
/tmp/ccYEBSct.o: In function `inst':
inst.c:(.text+0x0): multiple definition of `inst'
/tmp/ccNrTZCA.o:inst0.c:(.text+0x0): first defined here
/tmp/ccdZkuQl.o: In function `shel':
shel.c:(.text+0x0): multiple definition of `shel'
/tmp/ccNrTZCA.o:inst0.c:(.text+0xa3): first defined here
collect2: error: ld returned 1 exit status
需要修改一下inst0.c文件:
去掉 #include "inst.c"
#include "shel.c"
两句,
再进行编译:
gcc -o inst0 inst0.c inst.c shel.c
会生成可执行文件:ints0,
执行该文件:./inst0
Data:
20 19 18 17 16 15 14 13 12 11
30 29 28 27 26 25 24 23 22 21
40 39 38 37 36 35 34 33 32 31
50 49 48 47 46 45 44 43 42 41
60 59 58 57 56 55 54 53 52 51
Insert Sort:
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
Shell Sort:
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60