93c16edb5a
- 修正主README.md中的所有路径引用,使其与当前文件结构一致 - 更新翁凯C语言学习指南链接路径 - 更新五子棋AI项目文档链接路径 - 更新数据结构学习文档链接路径 - 修正编译说明和学习模块使用指南中的目录路径 - 改进五子棋README.md的编译运行说明,增加Windows和Linux/macOS的分平台指导 - 确保所有文档链接和路径引用都能正确工作
61 lines
1.2 KiB
C
61 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include <math.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#include <direct.h>
|
|
#endif
|
|
|
|
// !链表
|
|
/*
|
|
1.
|
|
*/
|
|
|
|
typedef struct _node{
|
|
int value;
|
|
struct _node *next;
|
|
} Node;
|
|
|
|
int main()
|
|
{
|
|
// 设置控制台编码为UTF-8
|
|
#ifdef _WIN32
|
|
system("chcp 65001 > nul"); // 设置控制台编码为UTF-8
|
|
SetConsoleOutputCP(65001); // 设置控制台输出编码
|
|
SetConsoleCP(65001); // 设置控制台输入编码
|
|
#endif
|
|
|
|
Node *head = NULL;
|
|
int number;
|
|
do {
|
|
printf("请输入一个整数:");
|
|
scanf("%d", &number);
|
|
if (number!=-1)
|
|
{
|
|
// 创建一个节点
|
|
Node *p=(Node*)malloc(sizeof(Node));
|
|
p->value = number;
|
|
p->next = NULL;
|
|
// 将节点插入链表
|
|
Node *last = head;
|
|
if (last!=NULL)
|
|
{
|
|
while (last->next!=NULL)
|
|
{
|
|
last = last->next;
|
|
}
|
|
// attach
|
|
last->next = p;
|
|
}
|
|
else
|
|
{
|
|
head = p;
|
|
}
|
|
}
|
|
} while (number!=-1);
|
|
|
|
return 0;
|
|
} |