学生成绩系统数据库代码(sql学生成绩管理数据库代码)
admin 发布:2022-12-19 17:07 133
今天给各位分享学生成绩系统数据库代码的知识,其中也会对sql学生成绩管理数据库代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
用SQL语言创建学生成绩数据库的代码
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CangKu]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CangKu]
GO
CREATE TABLE [dbo].[成绩] (
[学号] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[科目] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
...........
) ON [PRIMARY]
GO
用SQL语言如何创建学生成绩数据库的代码?
create database [数据库名];\x0d\x0auser [该数据库名];\x0d\x0a\x0d\x0a--学生表\x0d\x0acreate table [学生表表名](\x0d\x0asId int primary key, --学生ID编号,主键\x0d\x0asName varchar(10) unique not null, --学生名字\x0d\x0a);\x0d\x0a\x0d\x0a--科目表\x0d\x0acreate table [科目表表名](\x0d\x0asjId int primary key, --科目ID编号,主键\x0d\x0asjName varchar(10) unique not null, --科目名称\x0d\x0a);\x0d\x0a\x0d\x0a--成绩表\x0d\x0acreate table [成绩表表名]\x0d\x0arId int primary key, --成绩ID编号,主键\x0d\x0asjId int references [科目表表名](sjId), --科目ID编号,继承科目表的ID编号\x0d\x0asId int references [学生表表名](sId), --学生ID编号,继承学生表的ID编号\x0d\x0aresult float not null --成绩\x0d\x0a);\x0d\x0a\x0d\x0a--查询语句\x0d\x0aselect r.rId,sj.sjId,sj.sjName,su.sId,su.sName,r.result \x0d\x0afrom [成绩表表名] r,\x0d\x0ajoin [科目表表名] sj on sj.sjId=r.sjId,\x0d\x0ajoin [学生表表名] su on su.sId=r.sId;
学生成绩管理系统代码
#includeiostream
#includestring
#includefstream
#includecstdlib
#includeiomanip
using namespace std;
class student
{ private:
char name[20]; //姓名
double cpro,english,math,sport,law,hbpro,computer;//课程
int order, number; //名次,学号
public:
student(){}
student(char n[20],int nu,double cc,double eng,double ma,double sp,double l,double hb,double com)
{strcpy(name,n);
number=nu;
cpro=cc; english=eng;math=ma;sport=sp;law=l;hbpro=hb;computer=com;
}
friend void main();
};
void main()
{
cout" 欢迎进入**学生成绩管理系统**!"endl;
cout" ******************************************"endl;
cout" **** 学生成绩管理系统 ****"endl;
cout" ******************************************"endl;
cout" **************************"endl;
cout" **0、输入数据 **"endl;
cout" **1、增加数据 **"endl;
cout" **2、修改数据 **"endl;
cout" **3、按姓名查询 **"endl;
cout" **4、按学号查询 **"endl;
cout" **5、输出所有学生的成绩 **"endl;
cout" **6、退出系统 **"endl;
cout" **************************"endl;
cout" 选择0-6数字进行操作"endl;
char p;char w;
student *s[50]; //指针对象,最多存50个学生数据
ofstream *file[50]; //负责对文件插入操作
int i=0;
int j=0;
int flag=0;
do //flag判断输入是否有效
{
cinp;
if((p='0'p='6'))
flag=1;
else
cout" 指令错误!请重新输入:"endl;
}while(flag==0);
do{
switch(p) //接收功能选项
{
case '0': //输入数据
{
char c;
char name[20];int number;double cpro,english,math,sport,law,hbpro,computer;
do{
cout" 请输入姓名:";
cinname;
coutendl" 请输入学号:";
cinnumber;
cout" 请输入C++成绩:";
cincpro;
coutendl" 请输入英语成绩:";
cinenglish;
coutendl" 请输入数学成绩:";
cinmath;
coutendl" 请输入体育成绩:";
cinsport;
coutendl" 请输入网络基础成绩:";
cinlaw;
coutendl" 请输入C语言成绩:";
cinhbpro;
coutendl" 请输入数据库成绩:";
cincomputer;
coutendl;
file[j]=new ofstream("D:\document",ios::ate);
*file[j]" 姓名 "name" 学号 "number" C++成绩 "cpro
" 英语成绩 "english" 数学成绩 "math" 体育成绩 "
sport" 网络基础成绩 "law" C成绩 "hbpro" 数据库成绩 "computerendl;
j++;
s[i]=new student(name, number,cpro,english,math,sport,law,hbpro,computer);
i++;
cout" 数据输入成功,想继续输入吗(y/n):";
cinc;
coutendl;
do
{
if(c!='y'c!='n')
{
cout" 指令错误!请重新输入!"endl" ";
cinc;
}
else
flag=1;
}while(flag==0);
}while(c=='y');
break;
}
case '1': //增加数据
{
char name[20];
int number;double cpro,english,math,sport,law,hbpro,computer;
char c;
do
{
cout" 请输入您要增加的学生的姓名:";
cinname;
coutendl" 请输入学号:";
cinnumber;
coutendl" 请输入C++成绩:";
cincpro;
coutendl" 请输入英语成绩:";
cinenglish;
coutendl" 请输入数学成绩:";
cinmath;
coutendl" 请输入体育成绩:";
cinsport;
coutendl" 请输入网络基础成绩:";
cinlaw;
coutendl" 请输入C语言成绩:";
cinhbpro;
coutendl" 请输入数据库成绩:";
cincomputer;
coutendl;
file[j]=new ofstream("d:\document",ios::ate);
*file[j]" 姓名 "name" 学号 "number" C++成绩 "cpro" 英语成绩 "english" 数学成绩 "math" 体育成绩 "sport" 网络基础成绩 "law" C成绩 "hbpro" 数据库成绩 "computerendl;
j++;
s[i]=new student(name, number, cpro,english,math,sport,law,hbpro,computer);
i++;
cout" 数据输入成功,想继续数入吗(y/n):";
cinc;
coutendl;
if(c!='y'c!='n')
{
cout" 指令错误!请重新输入!"endl" ";
cinc;
}
}while(c=='y');
break;
}
case '2': //修改数据
{
char name[20];int nu;double cc,eng,ma,sp,l,hb,com;flag=0;
char c;
if(i==0)
{
cout" 管理系统中没有输入数据!"endl;break;
}
do
{
cout" 请输入您要修改的学生的姓名:";
cinname;
coutendl;
for(int h=0;hi;h++) //h纪录要修改学生的位置
{
if(strcmp(name,s[h]-name)==0)
{
flag=1;
cout" 请输入新的学号:";
cinnu;
coutendl" 请输入C++成绩:";
cincc;
coutendl" 请输入英语成绩:";
cineng;
coutendl" 请输入数学成绩:";
cinma;
coutendl" 请输入体育成绩:";
cinsp;
coutendl" 请输入网络基础成绩:";
cinl;
coutendl" 请输入C语言成绩:";
cinhb;
coutendl" 请输入数据库成绩:";
cincom;
coutendl;
s[h]-cpro=cc;
s[h]-english=eng;
s[h]-math=ma;
s[h]-sport=sp;
s[h]-law=l;
s[h]-hbpro=hb;
s[h]-computer=com;
s[h]-number=nu;
cout" 数据修改成功!"endl;
}
}
if(flag==0)
{
cout" 您要修改的学生本来就不存在!请检查重新输入!"endl;
}
cout" 想继续修改吗(y/n):";
cinc;
coutendl;
if(c!='y'c!='n')
{
cout" 指令错误!请重新输入!"endl" ";
cinc;
}
}while(c=='y');
break;
}
case '3': //按姓名查询
{
char n[20];int j=0;char c;
if(i==0)
{
cout" 管理系统中没有输入数据!"endl;break;
}
do{
int flag=0;
cout" 请输入你要查询的学生姓名:";
cinn;
coutendl;
for(int j=0;ji;j++)
{
if(strcmp(n,(*s[j]).name)==0)
{
flag=1;
cout" 您要查询的学生是:"(*s[j]).nameendl;
cout(*s[j]).name"的成绩是: "" C++: "(*s[j]).cpro" 英语: "(*s[j]).english" 数学:"(*s[j]).math" 体育:"(*s[j]).sport" 法律:"(*s[j]).law" C:"(*s[j]).hbpro" 数据库 "(*s[j]).computerendl;
}
}
if(flag==0)
cout" 对不起!您要查询的学生不存在!"endl;
cout" 您想继续查询吗?(y/n):";
cinc;
coutendl;
if(c!='y'c!='n')
{
cout" 指令错误!请重新输入!"endl;
cinc;
}
}
while(c=='y');
break;
}
case '4': //按学号查询
{
int n,j=0;char c;
if(i==0){
cout" 管理系统中没有输入数据!"endl;break;
}
do{
int flag=0;
cout" 请输入你要查询的学生的学号:";
cinn;
coutendl;
for(int j=0;ji;j++)
{
if(s[j]-number==n)
{
flag=1;
cout" 您要查询的学生是:"(*s[j]).nameendl;
cout(*s[j]).name"的成绩是: "" C++:"(*s[j]).cpro" 英语:"(*s[j]).english" 数学:"(*s[j]).math" 体育:"(*s[j]).sport" 法律:"(*s[j]).law" C:"(*s[j]).hbpro" 数据库 "(*s[j]).computerendl;
}
}
if(flag==0)
cout" 对不起!您要查询的学生不存在!"endl;
cout" 您想继续查询吗?(y/n):";
cinc;
coutendl;
if(c!='y'c!='n')
{
cout" 指令错误!请重新输入!"endl;
cinc;
}
}
while(c=='y');
break;
}
case '5': //输出
{
cout" 本系统所有学生数据如下:"endl;
if(i==0)
cout" 管理系统中没有输入数据!"endl;
cout" 姓名 学号 c++ 英语 数学 体育 网络基础 C语言 数据库 "endl;
for(int k=0;ki;k++)
{
couts[k]-namesetw(7)s[k]-numbersetw(6)
(*s[k]).cprosetw(6)(*s[k]).englishsetw(6)
(*s[k]).mathsetw(6)(*s[k]).sportsetw(7)
(*s[k]).law setw(10)(*s[k]).hbprosetw(10)(*s[k]).computersetw(10)endl;
}
break;
}
case'6'://退出
{exit(0); cout"Bye bye!"endl;}
}
cout" 您想继续进行其他操作吗?(y/n):";
int flag=0;
do
{
cinw;
coutendl;
if(w!='y'w!='n')
cout" 指令错误!请重新输入!"endl;
else
flag=1;
}while(flag==0);
if(w=='y')
cout" 请输入操作代码:0 输入数据"endl;
cout" 1 增加数据"endl;
cout" 2 修改数据"endl;
cout" 3 按姓名查询"endl;
cout" 4 按学号查找"endl;
cout" 5 输出所有学生成绩"endl;
cout" 6 退出系统"endl;
cinp;
}while(w=='y');
}
关于学生成绩系统数据库代码和sql学生成绩管理数据库代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 05-14上海网站推广系统,上海网站推广服务公司
- 05-13电脑系统优化软件哪个好用,电脑系统优化在哪里
- 05-12网站自然优化,网站自动优化系统
- 05-12cms系统,喜来健CMS系统
- 05-11自助建站系统源码,自助建站源码php
- 05-09网页代码,网页代码快捷键
- 05-08青岛关键词排名系统,青岛关键词排名首页
- 05-07网易推广员系统登录,网易推广员系统推广平台
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接