基于链表的打字练习统计软件,运用ege和devc++进行实现,要能对用户进行管理
2条回答 默认 最新
- 踢足球的阿坤 2023-02-17 22:25关注
定义链表数据结构
通过定义链表数据结构,可以用来存储用户的相关信息,包括用户名,用户ID,打字速度,统计次数和时间等。struct userInfo{ int userID; char userName[20]; int typingSpeed; int totalCount; int totalTime; struct userInfo *next; };
创建链表
在程序开始时,创建一个头结点,用来存储用户信息,每次添加新用户,都可以把新用户添加到头结点后面。struct userInfo head; head = (struct userInfo)malloc(sizeof(struct userInfo)); head -> userID = 0; head -> next = NULL;
添加用户
根据用户输入,把用户的信息添加到链表中,添加的时候,需要把用户的ID和名字检测是否重复,确保添加的用户不会重复。struct userInfo p; p = (struct userInfo)malloc(sizeof(struct userInfo)); if (check_userinfo(userID, userName)) { p -> userID = userID; p -> userName = userName; p -> typingSpeed = 0; p -> totalCount = 0; p -> totalTime = 0; p -> next = head -> next; head -> next = p; }
统计数据
每次用户进行打字练习,就对用户进行统计,记录用户的打字速度,累计次数,累计时间等,把统计数据存放到链表中。struct userInfo *p; p = head -> next; while (p != NULL) { if (p -> userID == userID) { p -> typingSpeed = typingSpeed; p -> totalCount += 1; p -> totalTime += time; } p = p -> next; }
输出数据
把统计完成的用户数据,以 Markdown 格式输出,方便用户查看。struct userInfo *p; p = head -> next; while (p != NULL) { printf("|UserID|UserName|TypingSpeed|TotalCount|TotalTime|\n"); printf("|------|--------|-----------|----------|---------|\n"); printf("|%d |%s |%d |%d |%d |\n", p -> userID, p -> userName, p -> typingSpeed, p -> totalCount, p -> totalTime); p = p -> next; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥60 求一个简单的网页(标签-安全|关键词-上传)
- ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
- ¥15 基于卷积神经网络的声纹识别
- ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
- ¥100 为什么这个恒流源电路不能恒流?
- ¥15 有偿求跨组件数据流路径图
- ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
- ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
- ¥15 CSAPPattacklab
- ¥15 一直显示正在等待HID—ISP