东北大学软件技术基础实验报告.doc

上传人:叶*** 文档编号:35177748 上传时间:2022-08-20 格式:DOC 页数:9 大小:48.50KB
返回 下载 相关 举报
东北大学软件技术基础实验报告.doc_第1页
第1页 / 共9页
东北大学软件技术基础实验报告.doc_第2页
第2页 / 共9页
点击查看更多>>
资源描述

《东北大学软件技术基础实验报告.doc》由会员分享,可在线阅读,更多相关《东北大学软件技术基础实验报告.doc(9页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、实验一代码: #include iostream#include / 定义一个线性表const int nMaxSize = 15;/ 最大值int nLen = 0;/ 表中元素个数int nLinearListnMaxSize;/ 定义操作void LSort();void LOut();void LInsert(int n);void LDelete(int n);void main() / 输入数据并放入线性表中printf(Please input datan);/ std:cout Please input datan;int nIn = 0;for (int i = 0; i n

2、In;nLinearListi = nIn;nLen+;LSort();/ 排序线性表LOut();/ 输出结果printf(Please input a data to insert n);scanf(%d,&nIn);LInsert(nIn);/ 输入一个数字,并插入到线性表中LOut();LSort();printf(sorted:n);LOut();while(1)printf(Please input a number of data to delete n);scanf(%d,&nIn);if (nInnLen) printf(number must less than %dn,n

3、Len);elsebreak;LDelete(nIn);/ 输入一个数字,并从线性表中删除LOut();char chTmp;printf(Please input a char to finish this program.);chTmp = getch();void LSort()/ 冒泡排序,由大到小int i,j,temp;for (j=0;jnLen;j+)for (i=0;inLen;i+)if (nLinearListinLinearListi+1)temp=nLinearListi;nLinearListi=nLinearListi+1;nLinearListi+1=temp;

4、void LOut()printf( n);for (int i = 0; i nLen) printf(place number must less than %dn,nLen);elsebreak;for(i = nLen; i = j ; -i)nLinearListi =nLinearListi - 1;nLinearListj-1 = k;nLen+;void LDelete(int m)int i;for(i = m; i = nLen; +i)nLinearListi-1 = nLinearListi;nLen-;实验二代码:#include #include #include

5、#include const int MAX_LEN = 10;/ 字符串的长度const int MAX_SIZE = 30;/ 栈或队的最大元素个数/ 定义一个队列的结构struct QUEUE int nMaxSize;/ 最大值int nCount;/ 个数int nFront;/ 头int nRear;/ 尾char szQueueMAX_SIZEMAX_LEN;/定义一个栈的结构struct STACK int nMaxSize;/ 最大值int nTop;/ 栈顶char szStackMAX_SIZEMAX_LEN;/ 队列的操作void InitQueue(QUEUE *q,

6、int nMaxSize)q-nMaxSize=nMaxSize;q-nCount=0;q-nFront=0;q-nRear=0;q-szQueueMAX_SIZEMAX_LEN=0;void InQueue(QUEUE *q, char *pItem)if(q-nCount=q-nMaxSize)printf(Queue is full!n);return;strcpy(q-szQueueq-nRear,pItem);if(q-nRear+=MAX_SIZE)q-nRear=0;q-nCount+;void OutQueue(QUEUE *q, char *pItem)if(q-nCount

7、=0)printf(Queue is empty!n);return;strcpy(pItem,q-szQueueq-nFront);if(q-nFront+=MAX_SIZE)q-nFront=0;q-nCount-;/栈的操作void InitStack(STACK *s,int nMaxSize) s-nMaxSize=nMaxSize;s-nTop=0;s-szStackMAX_SIZEMAX_LEN=0;void PushStack(STACK *s, char *pItem)char *p;if (s-nTopnMaxSize)p=s-szStacks-nTop;strcpy(p,

8、pItem);s-nTop+;elseprintf(stack overflow!n);return;void PopStack(STACK *s, char *pItem)char *p;if (s-nTop=0)printf(stack is empty!n);return;elsep=s-szStack-s-nTop;strcpy(pItem,p);void GetTopStack(STACK *s, char *pItem)char *p;char a10=0;if (s-nTop=0)a0=;strcpy(pItem,a);elsep=s-szStacks-nTop-1;strcpy

9、(pItem,p);/字符判断int isdigit(char x)if (x=0&xnCount!=0)OutQueue(q, x);printf(%s,x);if (isdigit(x0)/ 是数 PushStack(n,x); else/ 认为是运算符,没有考虑空格等GetTopStack(o,op);/ 获得OS栈顶运算符if (x0 = ; & op0 = ;)/ 扫描结束 printf(n result is );break;if (Priority(x) Priority(op)/ 运算符的优先级栈顶运算符PushStack(o,x);continue;while (Priori

10、ty(x) = Priority(op)&Priority(op)/ 不大于栈顶运算符 PopStack(n,num1);PopStack(n,num2);PopStack(o,op);Compute(num2,num1,op,chResult);PushStack(n,chResult);GetTopStack(o,op);PushStack(o,x);PopStack(n,chResult);printf(%sn,chResult);int Priority(char *op )int nPriority = 0;switch (op0)case :nPriority = 3;break;

11、case *:case /:nPriority = 2;break;case +:case -:nPriority = 1;break;case ;:nPriority = 0;return nPriority;void Compute(char *num1, char *num2, char *op, char *chResult)double fNum1,fNum2;double fResult = 0;fNum1 = atof(num1);fNum2 = atof(num2);switch (op0)case :fResult = pow(fNum1,fNum2);break;case

12、*:fResult = fNum1*fNum2;break;case /:fResult = fNum1/fNum2;break;case +:fResult = fNum1+fNum2;break;case -:fResult = fNum1-fNum2;break;sprintf(chResult,%.4f,fResult);/把计算的结果转化为字符串return;运行结果实验三程序CREATE DATABASE myDBCREATE TABLE stub(Sno CHAR(8)PRIMARY KEY, SNAME CHAR(10), Sex CHAR(2), Age int, Birth

13、day datetime, class CHAR(10);Create table Courseb (Cno char(2) primary key, Cname char(10) , Chour int);Create table Scoreb (Sno char(8), CnO char(2), Grade int, Primary key (Sno,CnO), Foreign key (Sno) references Stub(Sno), Foreign key (CnO) references Courseb(CnO);Insert into stub (Sno,sname,sex,a

14、ge,birthday,class )values (0101,zhangqiang,m,20,19940220,zdh01);Insert into stub (Sno,sname,sex,age,birthday,class )values (0102,lihong,f,20,19940810,zdh01);Insert into stub (Sno,sname,sex,age,birthday,class )values (0103,wangtao,m,21,19930518,zdh01)Insert into stub (Sno,sname,sex,age,birthday,class

15、 )values (0104,liuli,f,19,19950305,zdh02);Insert into stub (Sno,sname,sex,age,birthday,class )values (0105,sundong,m,21,19931217,zdh02);Insert into stub (Sno,sname,sex,age,birthday,class )values (0106,wangping,m,22,19921130,zdh02);Insert into stub (Sno,sname,sex,age,birthday,class )values (0201,ouya

16、ngyan,f,20,19940411,dz01);Insert into stub (Sno,sname,sex,age,birthday,class )values (0202,ouyangyan,f,20,19940411,dz01);Insert into stub (Sno,sname,sex,age,birthday,class )values (0203,liuyan,f,18,19960121,dz01);Insert into stub (Sno,sname,sex,age,birthday,class )values (0204,zhouyu,m,20,19940710,d

17、z01);Insert into Courseb (Cno ,Cname ,Chour )values (01,jsj,48);Insert into Courseb (Cno ,Cname ,Chour )values (02,java,32);Insert into Scoreb (Sno ,CnO ,Grade )values (0101,01,87);Insert into Scoreb (Sno ,CnO ,Grade )values (0102,01,90);Insert into Scoreb (Sno ,CnO ,Grade )values (0103,01,79);Inser

18、t into Scoreb (Sno ,CnO ,Grade )values (0104,01,89);Insert into Scoreb (Sno ,CnO ,Grade )values (0105,01,58);Insert into Scoreb (Sno ,CnO ,Grade )values (0106,01,77);Insert into Scoreb (Sno ,CnO ,Grade )values (0201,01,95);Insert into Scoreb (Sno ,CnO ,Grade )values (0202,01,80);Insert into Scoreb (

19、Sno ,CnO ,Grade )values (0203,01,76);Insert into Scoreb (Sno ,CnO ,Grade )values (0204,01,70);Insert into Scoreb (Sno ,CnO ,Grade )values (0101,02,91);Insert into Scoreb (Sno ,CnO ,Grade )values (0102,02,88);Insert into Scoreb (Sno ,CnO ,Grade )values (0103,02,75);Insert into Scoreb (Sno ,CnO ,Grade

20、 )values (0104,02,91);Insert into Scoreb (Sno ,CnO ,Grade )values (0105,02,76);Insert into Scoreb (Sno ,CnO ,Grade )values (0106,02,76);Insert into Scoreb (Sno ,CnO ,Grade )values (0201,02,90);Insert into Scoreb (Sno ,CnO ,Grade )values (0202,02,84);Insert into Scoreb (Sno ,CnO ,Grade )values (0203,

21、02,83);Insert into Scoreb (Sno ,CnO ,Grade )values (0204,02,57);1、查询学生出生日期(Sno, Sname, BirthDay);select distinct sno,sname,birthday from stub2、按学号顺序查询自动化02班的所有学生(Class, Sname);select distinct sno,sname,class from stub where class =zdh02 order by sno3、列出学生选择各门课程的成绩(Sname, Cname, Grade) ;select distin

22、ct SNAME,Cname,Grade from Stub,Courseb,Scoreb where Stub.Sno=Scoreb.Sno AND Courseb.Cno=Scoreb.Cno; 4、列出有过不及格成绩的学生名单(Sno, Sname, Class);select distinct stub.Sno,sname,CLASS from stub,Scoreb where stub.Sno=Scoreb.Sno and Grade= 85 分的学生(Sname, Class);select distinct stub.Sno,sname,CLASS from stub,Scor

23、eb where stub.Sno=Scoreb.Sno and Grade=857、将课程号为“01”的课程名称修改为“软件技术”;update Courseb set Cname=RJJS where Cno=01select distinct * from Courseb8、修改一名学生的姓名、性别、年龄;update stub set Sname=xuyiyang,sex=f,age=20 where Sno=01019、将成绩为5559分的男生的成绩修改为60分;update Scoreb set Grade=60 where Sno in(SELECT Sno FROM Stub

24、where Sex=m) AND Grade BETWEEN 55 AND 59;10、删除年龄不是20的学生的所有信息(包括选课和成绩);DELETE Stub WHERE Sno IN(SELECT Sno FROM Stub WHERE Age !=20)DELETE scoreb WHERE Sno IN(SELECT Sno FROM Stub WHERE Age !=20)11、删除一个班级的所有学生;DELETE Stub WHERE Sno IN(SELECT Sno FROM Stub WHERE class=dz01);DELETE Scoreb WHERE Sno IN(SELECT Sno FROM Stub WHERE class=dz01);12、删除所有数据表和数据库Drop database myDB

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高中资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com