Re: 程設

看板 Marginalman
作者 wwndbk (snoopy養的狗)
時間 2022-12-07 10:48:06
留言 6則留言 (1推 0噓 5→)

我剛剛問的 我也不會寫 #include <stdio.h> #include <stdlib.h> #include <string.h> // Define a struct for the nodes in the linked list struct Node { char* name; int score; int studentID; struct Node* next; }; int main() { // Open the text file in read mode FILE* input = fopen("text.txt", "r"); // Read the data from the file and print it to the console char line[256]; while (fgets(line, sizeof(line), input)) { printf("%s", line); } // Close the file fclose(input); // Create the first node in the list struct Node* head = malloc(sizeof(struct Node)); head->name = "Alice"; head->score = 100; head->studentID = 123456; // Create the second node in the list struct Node* second = malloc(sizeof(struct Node)); second->name = "Bob"; second->score = 95; second->studentID = 234567; // Link the two nodes together head->next = second; // Read the input value int input; scanf("%d", &input); // Loop through the list and output the data in the specified order struct Node* current = head; while (current != NULL) { if (input == 123) { printf("%s %d %d\n", current->name, current->score, current->studentID); } else if (input == 213) { printf("%d %s %d\n", current->score, current->name, current->studentID); } current = current->next; } return 0; } -- 我用中文問的 但他回答好像預設英文 可以叫他回答中文 超屌 https://i.imgur.com/I031tit.jpg 我也不知道 可能我第一句跟他說hi
他就預設我是英文使用者
※ 批踢踢實業坊(ptt.cc), 來自: 140.113.87.123 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1670381288.A.40C.html

medama: 大師 12/07 10:48

wwndbk: 笑死 差超多 12/07 10:48

medama: 為什麼你註解都是英文啊 你用英文問的嗎 12/07 10:49

surimodo: 大師 12/07 10:49

medama: 沒啊 你看我上一篇 他回我中文 12/07 10:53

medama: 原來如此 12/07 10:56

您可能感興趣