C++学生管理系统


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include <windows.h>
using std::endl;
using std::cin;
using std::cout;
#define NAMESIZE 20
#define FILENAME "学生成绩.dat"
const char* subject[6] = { "语文","数学","英语","物理","化学","生物" };
class Human {
public:
	char name[NAMESIZE] = { '\0' };
	int age;
	double height;
	double weight;
};
typedef class Student:public Human {
public:
	int info=0;
	int arr[6]={0};
	struct Student* next;
}SN, * SNL;
class stuSystem {
private:
	SNL shead;
public:
	stuSystem();
	int ADD();
	int SORT();
	int SORT(int index);
	int SEARCH();
	int CHANGE();
	int FILEREAD();
	int FILEWRITE();
	int SHOW();
	int MENU();
	int DEL();
	SNL INIT();
	int wait();
	int WrongInput(const char* warn);
	int color(int x);
	int AddScore(const int info, const int arr[6], const char name[NAMESIZE]);
};
int delwar;
int System();

int main(int argc, char** argv)
{
	System();
	return 0;
}
stuSystem::stuSystem() {
	this->shead = INIT();
	for (int i = 0; i < 6; i++)
		this->shead->arr[i] = 0;
	this->shead->info = 0;
	this->shead->next = NULL;
}
int stuSystem::SORT()
{
	SNL shead = this->shead;
	if (!shead || !(shead->next))
	{
		WrongInput("链表头不存在,无法排序");
		return -1;
	}
	else {
		SNL s1, s2;
		s1 = shead->next;
		while (s1)
		{
			s2 = s1->next;
			while (s2)
			{
				int sum1 = 0;
				int sum2 = 0;
				for (int i = 0; i < 6; i++)
				{
					sum1 += s1->arr[i];
					sum2 += s2->arr[i];
				}
				if (sum1 < sum2)
				{
					int temp;
					temp = s1->info;
					s1->info = s2->info;
					s2->info = temp;
					for (int i = 0; i < 6; i++)
					{
						int temp;
						temp = s1->arr[i];
						s1->arr[i] = s2->arr[i];
						s2->arr[i] = temp;
					}
					char name1[NAMESIZE] = { '\0' };
					char name2[NAMESIZE] = { '\0' };
					strcpy(name1, s1->name);
					strcpy(name2, s2->name);
					for (int i = 0; i < NAMESIZE; i++)
					{
						s1->name[i] = s2->name[i] = '\0';
					}
					strcpy(s1->name, name2);
					strcpy(s2->name, name1);
				}
				s2 = s2->next;
			}
			s1 = s1->next;
		}
		cout << endl;
		cout << "\t\t\t\t\t";
		cout << "排序成功";
		cout << endl;
	}
	return 0;
}
int stuSystem::SORT(int index)
{
	SNL shead = this->shead;
	if (!shead || !(shead->next))
	{
		WrongInput("链表头不存在,无法排序");
		return -1;
	}
	else {
		SNL s1, s2;
		s1 = shead->next;
		while (s1)
		{
			s2 = s1->next;

			while (s2)
			{
				if (s1->arr[index-1] < s2->arr[index-1])
				{
					int temp;
					temp = s1->info;
					s1->info = s2->info;
					s2->info = temp;
					for (int i = 0; i < 6; i++)
					{
						int temp;
						temp = s1->arr[i];
						s1->arr[i] = s2->arr[i];
						s2->arr[i] = temp;
					}
					
					char name1[NAMESIZE] = { '\0' };
					char name2[NAMESIZE] = { '\0' };

					strcpy(name1, s1->name);
					strcpy(name2, s2->name);

					for (int i = 0; i < NAMESIZE; i++)
					{
						s1->name[i] = s2->name[i] = '\0';
					}
					strcpy(s1->name, name2);
					strcpy(s2->name, name1);
				}
				s2 = s2->next;
			}
			s1 = s1->next;
		}
		cout << endl;
		cout << "\t\t\t\t\t";
		cout << "排序成功";
		cout << endl;
	}
	return 0;
}
int stuSystem::DEL()
{
	int info;
	SNL shead = this->shead;
	cout << endl << endl << endl;
	cout << "\t\t\t\t\t";
	cout << "输入学号: ";
	cin >> info;
	while (shead->next)
	{
		if (shead->next->info == info)
		{
			SNL delnode = shead->next;
			shead->next = shead->next->next;
			free(delnode);
			cout << endl;
			cout << "\t\t\t\t\t";
			cout<<"删除成功";
			cout << endl;
			return 0;
		}
		shead = shead->next;
	}
	WrongInput("查无此人");
	return 0;
}
int stuSystem::SEARCH()
{
	int info;
	SNL shead = this->shead;
	cout << endl << endl << endl;
	cout << "\t\t\t\t\t";
	cout<<"输入学号: ";
	cin >> info;
	while (shead->next)
	{
		if (shead->next->info == info)
		{


			printf("\n\t\t  %10d%8s%8d%8d%8d%8d%8d%8d",
				shead->next->info, 
				shead->next->name, 
				shead->next->arr[0],
				shead->next->arr[1], 
				shead->next->arr[2], 
				shead->next->arr[3],
				shead->next->arr[4], 
				shead->next->arr[5]);
			cout << endl;
			cout << "\t\t\t\t\t";
			cout << "查询成功";
			cout << endl;
			return 0;
		}
		shead = shead->next;
	}
	WrongInput("查无此人");
	return 0;
}
int stuSystem::CHANGE()
{
	int info;
	SNL shead = this->shead;
	cout << endl << endl << endl;
	cout << "\t\t\t\t\t";
	cout<<"输入学号: ";
	cin >> info;
	while (shead->next)
	{
		if (shead->next->info == info)
		{
			cout << endl;
			cout << endl;
			cout << endl;
			cout << "\t\t\t\t\t";
			cout << "输入姓名: ";
			for (int i = 0; i < NAMESIZE; i++) {
				shead->next->name[i] = '\0';
			}
			cin>>shead->next->name;
			for (int i = 0; i < 6; i++)
			{
				cout << "\t\t\t\t\t";
				cout<<"输入"<<subject[i]<<"成绩: ";
				cin>>shead->next->arr[i];
			}
			cout << endl;
			cout << "\t\t\t\t\t";
			cout<<"修改成功";
			cout << endl;
			return 0;
		}
		shead = shead->next;
	}
	WrongInput("查无此人");
	return 0;
}
int stuSystem::SHOW()
{
	SNL shead = this->shead;
	if (!shead || !(shead->next)) {
		WrongInput("无链表头或无数据,无法显示");
		return -1;
	}
	printf("\n\n\t\t\t学号\t姓名\t语文\t数学\t英语\t物理\t化学\t生物\n");
	while (shead->next)
	{
		printf("\n\t\t  %10d%8s%8d%8d%8d%8d%8d%8d",
			shead->next->info,
			shead->next->name,
			shead->next->arr[0],
			shead->next->arr[1],
			shead->next->arr[2],
			shead->next->arr[3],
			shead->next->arr[4],
			shead->next->arr[5]);
		shead = shead->next;
	}
	return 0;
}
int stuSystem::ADD()
{
	SNL shead = this->shead;
	if (!shead)
	{
		WrongInput("无链表头,无法添加");
		return -1;
	}
	int info;
	int arr[6];
	char name[NAMESIZE] = { '\0' };
	cout << endl;
	cout << endl;
	cout << endl;
	cout<<"\t\t\t\t\t输入学号: ";
	delwar = scanf("%d", &info);
	cout<<"\t\t\t\t\t输入姓名: ";
	delwar = scanf("%s", name);
	for (int i = 0; i < 6; i++)
	{
		printf("\t\t\t\t\t输入%s成绩: ", subject[i]);
		delwar = scanf("%d", &arr[i]);
	}
	AddScore(info, arr, name);
	cout<<"\t\t\t\t\t添加成功\n";
	return 0;

}
SNL stuSystem::INIT()
{
	SNL node = new SN;
	node->next = NULL;
	return node;
}
int stuSystem::color(int x) //设置字体颜色

{

	if (x >= 0 && x <= 15) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);
	}

	else {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
	}

	return 0;
}
int stuSystem::wait()
{
	cout << endl;
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t";
	cout<<"输入回车结束";
	cout << endl;
	char wait = getchar();
	wait = getchar();
	return 0;
}
int stuSystem::MENU()
{
	int choice;
	cout<<"\n\n\n";
	cout<<"\t\t\t\t\t██████████████████████████\n";
	cout<<"\t\t\t\t\t█                        █\n";
	cout<<"\t\t\t\t\t█        < 菜单 >        █\n";
	cout<<"\t\t\t\t\t█       1.增加成绩       █\n";
	cout<<"\t\t\t\t\t█       2.删除成绩       █\n";
	cout<<"\t\t\t\t\t█       3.修改成绩       █\n";
	cout<<"\t\t\t\t\t█       4.查询成绩       █\n";
	cout<<"\t\t\t\t\t█       5.显示成绩       █\n";
	cout<<"\t\t\t\t\t█       6.排序成绩       █\n";
	cout<<"\t\t\t\t\t█       0.退出           █\n";
	cout<<"\t\t\t\t\t█                        █\n";
	cout<<"\t\t\t\t\t██████████████████████████\n";
	cout<<"\n\t\t\t\t\t选择> ";
	cin >> choice;
	system("cls");
	return choice;
}
int stuSystem::WrongInput(const char* warn)
{
	system("cls");
	color(4);
	cout << endl << endl;
	cout << endl << endl;
	cout << endl << endl << endl;
	cout << "\t\t\t\t\t\t";
	cout<<warn;
	cout << endl;
	color(7);
	return 0;
}
int stuSystem::AddScore(const int info, const int arr[6], const char name[NAMESIZE])
{
	SNL shead = this->shead;
	if (!shead)
	{
		WrongInput("无链表头,无法添加");
		return 0;
	}
	while (shead->next) {
		shead = shead->next;
	}
	SNL snode = INIT();
	shead->next = snode;
	snode->info = info;
	for (int i = 0; i < 6; i++) {
		snode->arr[i] = arr[i];
	}
	strcpy(snode->name, name);
	return 0;
}
int stuSystem::FILEREAD()
{
	if (!shead)
	{
		WrongInput("链表头不存在,读取失败");
		return -1;
	}
	FILE* file = fopen(FILENAME, "r");
	if (!file)
	{
		WrongInput("文件不存在,读取失败");
		return -1;
	}
	while (!feof(file))
	{
		int info = -1;
		int arr[6];
		char name[NAMESIZE] = { '\0' };
		delwar = fscanf(file, "%d%s%d%d%d%d%d%d", 
			&info, 
			name, 
			&arr[0], 
			&arr[1], 
			&arr[2], 
			&arr[3], 
			&arr[4], 
			&arr[5]);
		if (info != -1) {
			AddScore(info, arr, name);
		}
	}
	fclose(file);
	return 0;
}
int stuSystem::FILEWRITE()
{
	if (!shead)
	{
		WrongInput("链表头不存在,写入失败");
		return -1;
	}
	FILE* file = fopen(FILENAME, "w");
	if (!file)
	{
		WrongInput("文件写入失败");
		return -1;
	}
	while (shead->next)
	{
		fprintf(file, "%d %s %d %d %d %d %d %d\n",
			shead->next->info, 
			shead->next->name, 
			shead->next->arr[0],
			shead->next->arr[1], 
			shead->next->arr[2], 
			shead->next->arr[3],
			shead->next->arr[4], 
			shead->next->arr[5]);
		shead = shead->next;
	}
	return 0;
}
int System()
{
	stuSystem* SYSTEM = new stuSystem();
	SYSTEM->FILEREAD();
	while (true)
	{
		switch (SYSTEM->MENU())
		{
		case 1:
			SYSTEM->ADD();
			break;
		case 2:
			SYSTEM->DEL();
			break;
		case 3:
			SYSTEM->CHANGE();
			break;
		case 4:
			SYSTEM->SEARCH();
			break;
		case 5:
			SYSTEM->SHOW();
			break;
		case 6:
			SYSTEM->SORT();
			break;
		case 0:
			cout<<"\n\n\n\n\n";
			cout<<"\t\t\t\t\t\t";
			cout<<"成功退出";
			SYSTEM->FILEWRITE();
			exit(0);
			break;
		default:
			SYSTEM->WrongInput("错误输入警告");
			break;
		}
		SYSTEM->wait();
		system("cls");
	}
}

### RT-DETRv3 网络结构分析 RT-DETRv3 是一种基于 Transformer 的实时端到端目标检测算法,其核心在于通过引入分层密集正监督方法以及一系列创新性的训练策略,解决了传统 DETR 模型收敛慢和解码器训练不足的问题。以下是 RT-DETRv3 的主要网络结构特点: #### 1. **基于 CNN 的辅助分支** 为了增强编码器的特征表示能力,RT-DETRv3 引入了一个基于卷积神经网络 (CNN) 的辅助分支[^3]。这一分支提供了密集的监督信号,能够与原始解码器协同工作,从而提升整体性能。 ```python class AuxiliaryBranch(nn.Module): def __init__(self, in_channels, out_channels): super(AuxiliaryBranch, self).__init__() self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1) self.bn = nn.BatchNorm2d(out_channels) def forward(self, x): return F.relu(self.bn(self.conv(x))) ``` 此部分的设计灵感来源于传统的 CNN 架构,例如 YOLO 系列中的 CSPNet 和 PAN 结构[^2],这些技术被用来优化特征提取效率并减少计算开销。 --- #### 2. **自注意力扰动学习策略** 为解决解码器训练不足的问题,RT-DETRv3 提出了一种名为 *self-att 扰动* 的新学习策略。这种策略通过对多个查询组中阳性样本的标签分配进行多样化处理,有效增加了阳例的数量,进而提高了模型的学习能力和泛化性能。 具体实现方式是在训练过程中动态调整注意力权重分布,确保更多的高质量查询可以与真实标注 (Ground Truth) 进行匹配。 --- #### 3. **共享权重解编码器分支** 除了上述改进外,RT-DETRv3 还引入了一个共享权重的解编码器分支,专门用于提供密集的正向监督信号。这一设计不仅简化了模型架构,还显著降低了参数量和推理时间,使其更适合实时应用需求。 ```python class SharedDecoderEncoder(nn.Module): def __init__(self, d_model, nhead, num_layers): super(SharedDecoderEncoder, self).__init__() decoder_layer = nn.TransformerDecoderLayer(d_model=d_model, nhead=nhead) self.decoder = nn.TransformerDecoder(decoder_layer, num_layers=num_layers) def forward(self, tgt, memory): return self.decoder(tgt=tgt, memory=memory) ``` 通过这种方式,RT-DETRv3 实现了高效的目标检测流程,在保持高精度的同时大幅缩短了推理延迟。 --- #### 4. **与其他模型的关系** 值得一提的是,RT-DETRv3 并未完全抛弃经典的 CNN 技术,而是将其与 Transformer 结合起来形成混合架构[^4]。例如,它采用了 YOLO 系列中的 RepNCSP 模块替代冗余的多尺度自注意力层,从而减少了不必要的计算负担。 此外,RT-DETRv3 还借鉴了 DETR 的一对一匹配策略,并在此基础上进行了优化,进一步提升了小目标检测的能力。 --- ### 总结 综上所述,RT-DETRv3 的网络结构主要包括以下几个关键组件:基于 CNN 的辅助分支、自注意力扰动学习策略、共享权重解编码器分支以及混合编码器设计。这些技术创新共同推动了实时目标检测领域的发展,使其在复杂场景下的表现更加出色。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

alasnot

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值