我有一個程序正在查找總數以及鏈接列表中的中間數字是什麼。我擁有的問題是爲什麼它不打印出值?C程序不會打印出值
下面是代碼:
int count(list values){
if(values == NULL)
return 0;
else
return 1 + count(values->next);
}
void middle(struct node *head){
int count = 0;
struct node *mid = head;
while (head != NULL){
if(count & 1)
mid = mid->next;
count++;
head = head->next;
}
}
void traverse(list values){
if(values->next)
printf("\n# of the values: %.1f% \nMiddle: %.1f%\n", count, middle);
}
int main(int argc, char *argv[]){
FILE *input = stdin;
list values = readNumbers(input);
traverse(values);
return 0;
}
向我們展示了整個代碼,請。 – Downvoter
什麼是預期和實際產出? –
列表readNumbers(FILE *文件){ \t列表值= NULL,第一= NULL; \t詮釋三; \t而((C = GETC(文件))= EOF!){ \t \t INT I = 0; \t \t \t \t列表新=( list)malloc(sizeof(struct node)); \t \t \t \t if(values == NULL)values = new; \t \t else { \t \t \t values-> next = new; \t \t \t values = new; \t \t} \t \t values = new; \t \t \t \t if(first == NULL)first = values; \t \t do { \t \t \t values-> value [i ++] = c; \t \t} while((c = getc(file))!='\ n'&& c!= EOF); \t \t values-> value [i] ='\ 0'; \t} \t首先返回; } – edge