社区
非技术区
帖子详情
数据结构(c++)课程设计(请各位大哥帮忙)
sjwsly3214
2004-12-21 12:35:12
制定教学计划
(1)根据先修课程拓扑图动态输入课程,包括(类别 课程 編号 课程名称 理论学时 试验学时。)
(2)每学期科目不得超过8个,总学时不得多于420学时,公共课必须在前两年开完
(3)按照上述要求实现教学计划的自动生成
(4)教学计划的结果按学习输出包括课程的各个属性
那位大哥用c++帮我做出来呀
...全文
263
15
打赏
收藏
数据结构(c++)课程设计(请各位大哥帮忙)
制定教学计划 (1)根据先修课程拓扑图动态输入课程,包括(类别 课程 編号 课程名称 理论学时 试验学时。) (2)每学期科目不得超过8个,总学时不得多于420学时,公共课必须在前两年开完 (3)按照上述要求实现教学计划的自动生成 (4)教学计划的结果按学习输出包括课程的各个属性 那位大哥用c++帮我做出来呀
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
15 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
sjwsly3214
2004-12-23
打赏
举报
回复
哪位大哥给小弟一个思路好往下编呀 帮帮忙呀
sjwsly3214
2004-12-23
打赏
举报
回复
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
struct COURSES
{
char course[30];
char kechengleixing[10];
float xuefen;
int xueshi;
int jiangshou;
int shiyan;
int shixi;
};
COURSES courses[50];
int term=1;
int indegree[10];
const MAX_VERTEX_NUM=30;
typedef int VertexType;
typedef struct ArcNode{
int adjvex;
struct ArcNode *nextarc;
}ArcNode;
typedef struct VNode{
VertexType data;
ArcNode *firstarc;
}VNode,AdjList[MAX_VERTEX_NUM];
typedef struct{
AdjList vertices;
int vexnum,arcnum;
}ALGraph;
struct Stack{
int *elem;
int top;
int stacksize;
};
const int STACK_INIT_SIZE=100;
const int STACKINCREMENT=10;
const int OVERFLOW=-1;
//初始化栈
void InitStack(Stack &S,int maxsize=STACK_INIT_SIZE)
{
S.elem=new int[STACK_INIT_SIZE];
if(!S.elem)exit(OVERFLOW);
S.top=-1;
S.stacksize=maxsize;
}
//压入栈
int Push(Stack &S,int e)
{
if((term+1)>4&&strcmp(courses[e].kechengleixing,"gonggong")==0){
cout<<"Shu Ru Cuo Wu"<<endl;
return 0;}
S.top++;
S.elem[S.top]=e;
}
//弹出栈
void Pop(Stack &S,int &e)
{
if(S.top==-1)cout<<"ERROR";
e=S.elem[S.top--];
}
//销毁栈
void DestoryStack(Stack &S){delete[]S.elem;}
//清空栈
void ClearStack(Stack &S){S.top=-1;}
//判空
int StackEmpty(Stack S)
{
if(S.top==-1)return 1;
else return 0;
}
void CopyStack(Stack &S1,Stack S2)
{
for(int i=0;i<=S2.top;i++)
S1.elem[i]=S2.elem[i];
S1.top=S2.top;
}
void CreateDG(ALGraph &G)
{
int j=0,v1,v2;
cout<<"Input courses:"<<endl;
cin>>courses[j].course>>courses[j].kechengleixing;
while(strcmp(courses[j].course,"#")!=0){++j;cin>>courses[j].course>>courses[j].kechengleixing;}
G.vexnum=j;
for(int i=0;i<G.vexnum;i++)
G.vertices[i].firstarc=NULL;
for(int k=0;k<G.vexnum;k++)
cout<<k+1<<":"<<courses[k].course<<" "<<courses[k].kechengleixing<<endl;
for(int h=0;h<G.vexnum;h++)
indegree[h]=0;
cout<<"Inpute the order:v1-->v2"<<endl;
cin>>v1>>v2;
while((v1>0)&&(v2>0)){
ArcNode *pi=new ArcNode;
pi->adjvex=v2-1;
pi->nextarc=G.vertices[v1-1].firstarc;
G.vertices[v1-1].firstarc=pi;
G.arcnum++;
indegree[v2-1]++;
cin>>v1>>v2;
}
}
void TopoSet(ALGraph G){
int count=0;
ArcNode *p;
Stack S1,S2;
InitStack(S1);
InitStack(S2);
for(int i=0;i<G.vexnum;i++)
if(indegree[i]==0)Push(S1,i);
cout<<term<<"TERM:"<<endl;
while((!StackEmpty(S1))||(!StackEmpty(S2))){
if((StackEmpty(S1))&&(!StackEmpty(S2))){
CopyStack(S1,S2);
ClearStack(S2);
term++;
cout<<term<<"TERM:"<<endl;
}
int v;
Pop(S1,v);++count;cout<<courses[v].course<<endl;
for(p=G.vertices[v].firstarc;p;p=p->nextarc){
int w;
w=p->adjvex;
--indegree[w];
if(!indegree[w])Push(S2,w);
}//for
}//while
if(count<G.vexnum)cout<<"THE NETWORK HAS A CYCLE"<<endl;
DestoryStack(S1);
DestoryStack(S2);
}
void main(){
ALGraph G;
CreateDG(G);
cout<<"The Tesult of a Toposet Sorting:"<<endl;
TopoSet(G);
}
我在S1中入的是入度为0的顶点证明它可在第一学期完成。在S2中入的是新产生的入度为0的
我用什么算法可以让栈S1中的公共课先输出呢???并且公共课输出后不满8科且总学时不到420时
再输出不是公共课的直到达到8科或是达到420学时为止.请各位大哥帮帮忙
drugon
2004-12-22
打赏
举报
回复
类是一个好方法的。
类中的变量不是也可以保存的吗?
sjwsly3214
2004-12-21
打赏
举报
回复
我用什么方式把个个属性存到一起呀
各位大哥帮忙呀
sjwsly3214
2004-12-21
打赏
举报
回复
不用栈用什么呀
谁帮我改改呀
dongyuanzhang
2004-12-21
打赏
举报
回复
心情能够理解,为什么要用栈呢?
sjwsly3214
2004-12-21
打赏
举报
回复
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
char course[30][30];
int indegree[10];
const MAX_VERTEX_NUM=30;
typedef int VertexType;
typedef struct ArcNode{
int adjvex;
struct ArcNode *nextarc;
}ArcNode;
typedef struct VNode{
VertexType data;
ArcNode *firstarc;
}VNode,AdjList[MAX_VERTEX_NUM];
typedef struct{
AdjList vertices;
int vexnum,arcnum;
}ALGraph;
struct Stack{
int *elem;
int top;
int stacksize;
};
const int STACK_INIT_SIZE=100;
const int STACKINCREMENT=10;
const int OVERFLOW=-1;
//初始化栈
void InitStack(Stack &S,int maxsize=STACK_INIT_SIZE)
{
S.elem=new int[STACK_INIT_SIZE];
if(!S.elem)exit(OVERFLOW);
S.top=-1;
S.stacksize=maxsize;
}
//压入栈
void Push(Stack &S,int e)
{
S.top++;
S.elem[S.top]=e;
}
//弹出栈
void Pop(Stack &S,int &e)
{
if(S.top==-1)cout<<"ERROR";
e=S.elem[S.top--];
}
//销毁栈
void DestoryStack(Stack &S){delete[]S.elem;}
//清空栈
void ClearStack(Stack &S){S.top=-1;}
//判空
int StackEmpty(Stack S)
{
if(S.top==-1)return 1;
else return 0;
}
void CopyStack(Stack &S1,Stack S2)
{
for(int i=0;i<=S2.top;i++)
S1.elem[i]=S2.elem[i];
S1.top=S2.top;
}
void CreateDG(ALGraph &G)
{
int j=0,v1,v2;
cin>>course[j];
while(strcmp(course[j],"#")!=0)cin>>course[++j];
G.vexnum=j;
for(int i=0;i<G.vexnum;i++)
G.vertices[i].firstarc=NULL;
for(int k=0;k<G.vexnum;k++)
cout<<k+1<<":"<<course[k]<<endl;
for(int h=0;h<G.vexnum;h++)
indegree[h]=0;
cout<<"Inpute the order:v1-->v2"<<endl;
cin>>v1>>v2;
while((v1>0)&&(v2>0)){
ArcNode *pi=new ArcNode;
pi->adjvex=v2-1;
pi->nextarc=G.vertices[v1-1].firstarc;
G.vertices[v1-1].firstarc=pi;
G.arcnum++;
indegree[v2-1]++;
cin>>v1>>v2;
}
cout<<indegree[1];
}
void TopoSet(ALGraph G){
int count=0,term=1;
ArcNode *p;
Stack S1,S2;
InitStack(S1);
InitStack(S2);
for(int i=0;i<G.vexnum;i++)
if(indegree[i]==0)Push(S1,i);
cout<<term<<"TERM:"<<endl;
while((!StackEmpty(S1))||(!StackEmpty(S2))){
if((StackEmpty(S1))&&(!StackEmpty(S2))){
CopyStack(S1,S2);
ClearStack(S2);
term++;
cout<<term<<"TERM:"<<endl;
}
int v;
Pop(S1,v);++count;cout<<course[v]<<endl;
for(p=G.vertices[v].firstarc;p;p=p->nextarc){
int w;
w=p->adjvex;
--indegree[w];
if(!indegree[w])Push(S2,w);
}//for
}//while
if(count<G.vexnum)cout<<"THE NETWORK HAS A CYCLE"<<endl;
DestoryStack(S1);
DestoryStack(S2);
}
void main(){
ALGraph G;
CreateDG(G);
cout<<"The Tesult of a Toposet Sorting:"<<endl;
TopoSet(G);
}
这是我的程序。没有那么多功能。如何把每科的属性加上呀 怎么样标记公共课呀
是在栈中加入吗
那位大哥帮我改改
sjwsly3214
2004-12-21
打赏
举报
回复
我想问一下如何才能使公共课在前两年开完
我应用什么方法呀
AIGPTchina
2004-12-21
打赏
举报
回复
多发贴!!
xuzheng318
2004-12-21
打赏
举报
回复
呵呵,没时间,帮楼主顶,楼主你到网上搜索一下!
pacman2000
2004-12-21
打赏
举报
回复
作业题向来不能靠抄别人的啊。
双杯献酒
2004-12-21
打赏
举报
回复
原来学校的课程是这样排出来的。
carambo
2004-12-21
打赏
举报
回复
这个基本上得需要你自己来写,但是不难。只有你自己写了,你才能体会数据结构和算法的精髓!
goodluckyxl
2004-12-21
打赏
举报
回复
THIS TOPIC SHOULD BE DELLED
IT MAKES ME UNCOMFORTALE
yevv
2004-12-21
打赏
举报
回复
晕倒啊
大哥
大姐帮
帮忙
!!!
学了
C++
和汇编,现在正在学习
数据结构
和微机原理,以后的
课程
中还会学习:数值计算方法、操作系统、软件工程学基础、数据库系统与Oracle、计算机网络、软件测试与维护、UML与面向对象方法学、多媒体技术概论、软件...
华为-软件开发工程师(JAVA/
C++
/C/Python/J
分布式了解吗3.
C++
类里面,能不能用memset对指针进行初始化4.unordered_map和map的区别5 中国航天投递 中国航天总体
设计
部软件开发(北京)简历筛选中 美团实习生招募 岗位职责:1:支持营销专栏-百亿补贴、特价栏目...
题解 | #统计每个月兔子的总数#--兔子数等于前两月之和
2、对
数据结构
与算法、计算机网络、操作系统。杭州华为OD 软测+软开 招聘岗位要求1、本科或以上学历,熟悉C/
C++
、java、python、前端任一门语言即可;2、对
数据结构
与算法、计算机网络、操作系统。下周二就回家了...
C++
和V
C++
学习方法
C++
和V
C++
学习方法 第一篇: 导航:第一篇 第二篇 第三篇 第四篇 第五篇 第六篇 VC学习方法精髓
题解 | #最长上升子序列(一)#
c++
&;&; java
请
这些23届校招毁三方的公司原地倒闭! 联想24届秋招倒计时1个月,27天带薪假,截止10月18日 不多说啥有没有关联知道的人自己心里清楚 不多说啥有没有关联知道的人自己心里清楚 华兴源创 华兴源创 第一次拒绝offer ...
非技术区
15,440
社区成员
58,165
社区内容
发帖
与我相关
我的任务
非技术区
C/C++ 非技术区
复制链接
扫一扫
分享
社区描述
C/C++ 非技术区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章