当前位置:网站首页>【golang从入门到实践】学生成绩管理系统
【golang从入门到实践】学生成绩管理系统
2022-07-24 08:00:00 【会振刀的程序员】
功能介绍
1、学生成绩系统增加
2、学生成绩系统删除
3、学生成绩系统查询
4、学生成绩系统修改
5、学生成绩系统信息获取
效果展示
golang学生成绩管理系统
编程思路
1、定义结构体:将每个学生的信息为一组进行存储
2、定义数组:储存学生信息结构体
设计:系统的所有功能围绕数组以及结构体进行相关操作
相关知识点
数组、结构体、for循环、goto跳转、if条件语句、输出输入函数
源代码
package main
import (
"fmt"
)
var studb []stu_msg
const screen = `1、添加学生成绩 2、删除学生成绩 3、修改学生成绩 4、查询学生成绩 5、获取学生成绩 6、退出`
var n string
type stu_msg struct {
stuid int
name string
math int
english int
golang int
}
func main() {
for {
fmt.Println(screen)
fmt.Print("请输入你的选择:")
fmt.Scan(&n)
switch n {
case "1":
var stu stu_msg
fmt.Print("请输入id:")
fmt.Scan(&stu.stuid)
fmt.Print("请输入姓名:")
fmt.Scan(&stu.name)
fmt.Print("请输入数学:")
fmt.Scan(&stu.math)
fmt.Print("请输入英语:")
fmt.Scan(&stu.english)
fmt.Print("请输入golang:")
fmt.Scan(&stu.golang)
studb = append(studb, stu)
fmt.Println("添加成功")
case "2":
var id int
fmt.Print("请输入要删除的学生的ID:")
fmt.Scan(&id)
i := 1
for index, v := range studb {
if v.stuid == id {
studb = append(studb[:index], studb[index+1:]...)
fmt.Println("删除成功")
break
}
if i == len(studb) {
fmt.Println("没有找到此学生!")
}
i++
}
case "3":
var id int
fmt.Print("请输入要修改学生的ID:")
fmt.Scan(&id)
i := 1
for index, v := range studb {
if v.stuid == id {
fmt.Println("id:", v.stuid, "name:", v.name, "math:", v.math, "english:", v.english, "golang:", v.golang)
fmt.Print("请输入姓名:")
fmt.Scan(&studb[index].name)
fmt.Print("请输入数学:")
fmt.Scan(&studb[index].math)
fmt.Print("请输入英语:")
fmt.Scan(&studb[index].english)
fmt.Print("请输入golang:")
fmt.Scan(&studb[index].golang)
fmt.Println("修改成功")
break
} else if i == len(studb) {
fmt.Println("没有找到此学生!")
}
i++
}
case "4":
var name string
fmt.Print("请输入要查询的学生的姓名:")
fmt.Scan(&name)
i := 1
for _, v := range studb {
if v.name == name {
fmt.Println("id:", v.stuid, "name:", v.name, "math:", v.math, "english:", v.english, "golang:", v.golang)
break
} else if i == len(studb) {
fmt.Println("没有找到此学生!")
}
i++
}
case "5":
for _, v := range studb {
fmt.Println("id:", v.stuid, "name:", v.name, "math:", v.math, "english:", v.english, "golang:", v.golang)
}
case "6":
goto end
}
}
end:
fmt.Println("成功退出")
}
边栏推荐
- Installation and use of Zen path & defect report & defect operation
- CNN-VINS
- Automatic test and manual test
- *Yolo5 learning * data experiment based on yolo5 face combined with attention model se
- Facing Tencent (actual combat) - Test Development - detailed explanation of interns (face experience)
- Eight part essay on software testing
- Zhouzhihua machine learning watermelon book chapter 2 model evaluation and selection - accuracy and model generalization evaluation method, self-help method and integrated learning
- Jetson AgX Orin source change
- 学习笔记总结篇(一)
- NFT概念究竟是怎么回事。。全面了解NFT市场、技术和案例
猜你喜欢

What is the NFT concept.. Fully understand NFT market, technology and cases

Super simple countdown code writing

NFT是什么?一篇文章搞懂NFT的概念

One click Copy and import of web interface data into postman

33 introduction to sparksql, dataframe and dataset

Devops essay
![[Beijiao] image processing: basic concepts, image enhancement, morphological processing, image segmentation](/img/b3/76d2bcdf4b9769fb6308b7dac9ceb5.jpg)
[Beijiao] image processing: basic concepts, image enhancement, morphological processing, image segmentation

QT | string generation QR code function

Robert operator, Sobel operator, Laplace operator

MySQL --- 子查询 - 标量子查询
随机推荐
Anaconda cannot shut down the method of forced shutdown
Use JMeter to analyze and test the lottery probability of the lottery interface
Movie recommendation system
P1305新二叉树题解
When does MySQL use table locks and row locks?
【MATLAB】(四)MATLAB在线性代数中的应用
Robot operation continuous learning thesis (1) original text reading and Translation -- primitive generation strategy learning without catastrophic forgetting in robot operation
Full revolutionary Siamese networks for object tracking translation
我在微软的这六个月
Debug No3 multi texture overlay
Binary search common questions
*Project recurrence * project implementation of thesis based on contextbasedemotionrecognitionusingematicdataset
13.Unity2D 横版 可上下左右移动的双向平台(双向行走+可移动+单独判定)+随机平台生成
*Code understanding * common function parsing in pytoch
学习笔记总结篇(一)
A Knight‘s Journey题解
Use of ArrayList
Simple Gateway - intranet server safely obtains external network data
多种优化方法打印100~200之间的素数
JMeter stress test index interpretation