Re: 程设

楼主: wwndbk (黑人问号)   2022-12-07 10:48:06
我刚刚问的
我也不会写
#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;
}
作者: medama ( )   2021-12-07 10:48:00
大师
楼主: wwndbk (黑人问号)   2021-12-07 10:48:00
笑死 差超多
作者: medama ( )   2022-12-07 10:49:00
为什么你注解都是英文啊 你用英文问的吗
作者: surimodo (好吃棉花糖)   2022-12-07 10:49:00
大师
作者: medama ( )   2022-12-07 10:53:00
没啊 你看我上一篇 他回我中文原来如此
作者: Ericz7000 (Ericz7000nolan)   2022-12-07 10:59:00
好屌 这是免费的吗
楼主: wwndbk (黑人问号)   2022-12-07 11:01:00
聊天功能免费 好像有一些特定功能要钱

Links booklink

Contact Us: admin [ a t ] ucptt.com