社区
非技术区
帖子详情
数据结构(c++)课程设计(请各位大哥帮忙)
sjwsly3214
2004-12-21 12:35:12
制定教学计划
(1)根据先修课程拓扑图动态输入课程,包括(类别 课程 編号 课程名称 理论学时 试验学时。)
(2)每学期科目不得超过8个,总学时不得多于420学时,公共课必须在前两年开完
(3)按照上述要求实现教学计划的自动生成
(4)教学计划的结果按学习输出包括课程的各个属性
那位大哥用c++帮我做出来呀
...全文
303
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
打赏
举报
回复
晕倒啊
CDOJ 1061 C - 秋实
大哥
与战争 STL set 迭代器
题目链接: C -秋实
大哥
与战争 Time Limit:1000MSMemory Limit:65535KB64bit IO Format:%lld & %llu SubmitStatusPracticeUESTC 1061 Appoint description: System Crawler (2016-04-23) De...
2015 UESTC
数据结构
专题C题 秋实
大哥
与快餐店 字典树
C - 秋实
大哥
与快餐店 Time Limit: 1 SecMemory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/59 Description 朝为田舍郎,暮登天子堂。秋实
大哥
从小就怀抱有远大的理想,所以他开了一家快餐店。秋实
大哥
根据菜的...
脸盆
大哥
的木桶
链接:https://ac.nowcoder.com/acm/problem/14670 来源:牛客网 时间限制:C/
C++
1秒,其他语言2秒 空间限制:C/
C++
131072K,其他语言262144K 64bit IO Format: %lld 题目描述 彩虹岛网红脸盆
大哥
最骄傲就是自己制作的木桶。一天????????????拿了????块木板,其中第????块木板的高度为ℎ????,他希望脸盆
大哥
能够用这些木板制作出精美的木...
C
数据结构
-并查集升级版
leetcode582,杀死进程。之前的帖子C
数据结构
-并查集介绍过并查集的用途,这道题是升级版本,每个进程有个父进程,指定杀死节点kill,那么他下面的子子孙孙也会被一并杀死。需要给出啥子某个指定节点后,具体哪些节点会被杀死。 1、在查找团队
大哥
的函数上需要优化。**如果发现某个小弟
大哥
是kill了,就不要继续向上找了,到此为止。**这样保证记录的数组中,一旦大佬是kill的,都标识成了kill...
非技术区
15,446
社区成员
58,112
社区内容
发帖
与我相关
我的任务
非技术区
C/C++ 非技术区
复制链接
扫一扫
分享
社区描述
C/C++ 非技术区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章