Re: 程設

看板Marginalman作者 (snoopy養的狗)時間3年前 (2022/12/07 10:48), 3年前編輯推噓2(206)
留言8則, 4人參與, 3年前最新討論串8/12 (看更多)
我剛剛問的 我也不會寫 #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; } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.87.123 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1670381288.A.40C.html

12/07 10:48, 3年前 , 1F
大師
12/07 10:48, 1F

12/07 10:48, 3年前 , 2F
笑死 差超多
12/07 10:48, 2F

12/07 10:49, 3年前 , 3F
為什麼你註解都是英文啊 你用英文問的嗎
12/07 10:49, 3F
我用中文問的 但他回答好像預設英文 可以叫他回答中文 超屌

12/07 10:49, 3年前 , 4F
大師
12/07 10:49, 4F
※ 編輯: wwndbk (140.113.87.123 臺灣), 12/07/2022 10:52:17

12/07 10:53, 3年前 , 5F
沒啊 你看我上一篇 他回我中文
12/07 10:53, 5F
https://i.imgur.com/I031tit.jpg
我也不知道 可能我第一句跟他說hi 他就預設我是英文使用者 ※ 編輯: wwndbk (140.113.87.123 臺灣), 12/07/2022 10:55:28

12/07 10:56, 3年前 , 6F
原來如此
12/07 10:56, 6F

12/07 10:59, 3年前 , 7F
好屌 這是免費的嗎
12/07 10:59, 7F

12/07 11:01, 3年前 , 8F
聊天功能免費 好像有一些特定功能要錢
12/07 11:01, 8F
文章代碼(AID): #1ZZ_xeGC (Marginalman)
文章代碼(AID): #1ZZ_xeGC (Marginalman)