我对下面的要求几乎没有帮助,因为我对C语法知之甚少.
我有这样的文件中的数据
73 54 57 [52]
75 73 65 [23]
65 54 57 [22]
22 59 71 [12]
22 28 54 [2]
65 22 54 73 [12]
65 28 54 73 [52]
22 28 65 73 [42]
65 54 57 73 [22]
22 28 54 73 [4]
Run Code Online (Sandbox Code Playgroud)
括号中的值表示该系列的出现.我需要根据顶部最大元素下降的数据的出现对这些数据进行排序,如下所示.
65 28 54 73 [52]
22 28 65 73 [42]
65 54 57 73 [22]
65 22 54 73 [12]
22 28 54 73 [4]
28 59 71 [122]
73 54 57 [52]
22 28 65 [26]
..
.
.
.
Run Code Online (Sandbox Code Playgroud)
等等...
什么是快速代码?
我正在尝试这个
#include<string.h>
#include <stdio.h>
int main() {
FILE *infile;
char fname[40]="resultFile1.txt";
char line[100];
int lcount=0;
if((infile = fopen(fname, "r")) == NULL) {
printf("Error Opening File.\n");
}
char *Arr[23];// need to be dynamic
while( fgets(line, sizeof(line), infile) != NULL ) {
stringArray[lcount]=line;
lcount++;
Arr[lcount]=line;
} fclose(infile);
int i;
for (i = 0; i < lcount; i++) {
printf(Arr[i]);// not able to get Arr
}
}
Run Code Online (Sandbox Code Playgroud)
unw*_*ind 10
我会:
qsort()使用比较函数调用我的行指针数组.