正在学习C语言--数据结构,请大家来帮忙

老师留了13题目,从中选取两个。请帮帮我设计一下,随便哪个都可以以。1一元多项式的表示及其运用(要求:包括相加,相减,相乘等运算)2集合的表示与运算3Josephu问题4... 老师留了13题目,从中选取两个。请帮帮我设计一下,随便哪个都可以以。1一元多项式的表示及其运用(要求:包括相加,相减,相乘等运算) 2集合的表示与运算 3Josephu问题 4航空客运订票系统 5马踏棋盘问题(设计法为非递归运算) 6文本编辑 7算术表达式求值问题 8迷宫问题(设计法为非递归法) 9哈夫曼/译码器 10一般树的储存表示及其基本操作的实现 11构造可以使n个城市连接的最小生成树 12图的遍历 13图像处理的金字塔算法 展开
 我来答
冒险岛乐乐
2008-12-31 · TA获得超过1969个赞
知道小有建树答主
回答量:621
采纳率:0%
帮助的人:0
展开全部
既然有200分,肯定得花点功夫:
所有程序在win-tc和DEV-C++下都运行通过,代码简练,执行正确。
200分这多题,划得来啊。请送分,谢谢。
第一题:
http://zhidao.baidu.com/question/80603134.html
第三题:
http://www.programfan.com/club/showtxt.asp?id=234730
这里还有固定密码的详细注释程序:
http://zhidao.baidu.com/question/77796518.html
第四题:
程序超过10000字,无法上传(这一个程序得200分)若有需要,留邮箱密我
第六题:
http://zhidao.baidu.com/question/79338502.html
第九题:
http://zhidao.baidu.com/question/80048763.html
第十题:
http://zhidao.baidu.com/question/79375216.html
第五题:递归算法,不是你的要求。
第十二题:图的广度优先遍历
/*******************************************/
/* 图形的广度优先搜寻法 */
/*******************************************/
#include <stdlib.h>
#include <stdio.h>
#define MAXQUEUE 10 /* 队列的最大容量 */
struct node /* 图的顶点结构定义 */
{
int vertex;
struct node *nextnode;
};
typedef struct node *graph; /* 图的结构指针 */
struct node head[9]; /* 图的顶点数组 */
int visited[9]; /* 遍历标记数组 */
int queue[MAXQUEUE]; /* 定义序列数组 */
int front = -1; /* 序列前端 */
int rear = -1; /* 序列后端 */
/***********************二维数组向邻接表的转化****************************/
void creategraph(int node[20][2],int num)
{
graph newnode; /* 顶点指针 */
graph ptr;
int from; /* 边起点 */
int to; /* 边终点 */
int i;
for ( i = 0; i < num; i++ ) /* 第i条边的信息处理 */
{
from = node[i][0]; /* 边的起点 */
to = node[i][1]; /* 边的终点 */
/* 建立新顶点 */
newnode = ( graph ) malloc(sizeof(struct node));
newnode->vertex = to; /* 顶点内容 */
newnode->nextnode = NULL; /* 设定指针初值 */
ptr = &(head[from]); /* 顶点位置 */
while ( ptr->nextnode != NULL ) /* 遍历至链表尾 */
ptr = ptr->nextnode; /* 下一个顶点 */
ptr->nextnode = newnode; /* 插入第i个节点的链表尾部 */
}
}
/************************ 数值入队列************************************/
int enqueue(int value)
{
if ( rear >= MAXQUEUE ) /* 检查伫列是否全满 */
return -1; /* 无法存入 */
rear++; /* 后端指标往前移 */
queue[rear] = value; /* 存入伫列 */
}
/************************* 数值出队列*********************************/
int dequeue()
{
if ( front == rear ) /* 队列是否为空 */
return -1; /* 为空,无法取出 */
front++; /* 前端指标往前移 */
return queue[front]; /* 从队列中取出信息 */
}
/*********************** 图形的广度优先遍历************************/
void bfs(int current)
{
graph ptr;
/* 处理第一个顶点 */
enqueue(current); /* 将顶点存入队列 */
visited[current] = 1; /* 已遍历过记录标志置疑1*/
printf(" Vertex[%d]\n",current); /* 打印输出遍历顶点值 */
while ( front != rear ) /* 队列是否为空 */
{
current = dequeue(); /* 将顶点从队列列取出 */
ptr = head[current].nextnode; /* 顶点位置 */
while ( ptr != NULL ) /* 遍历至链表尾 */
{
if ( visited[ptr->vertex] == 0 ) /*顶点没有遍历过*/
{
enqueue(ptr->vertex); /* 奖定点放入队列 */
visited[ptr->vertex] = 1; /* 置遍历标记为1 */

printf(" Vertex[%d]\n",ptr->vertex);/* 印出遍历顶点值 */
}
ptr = ptr->nextnode; /* 下一个顶点 */
}
}
}
/*********************** 主程序 ************************************/
/*********************************************************************/
int main()
{
graph ptr;
int node[20][2] = { {1, 2}, {2, 1}, /* 边信息数组 */
{6, 3}, {3, 6},
{2, 4}, {4, 2},
{1, 5}, {5, 1},
{3, 7}, {7, 3},
{1, 7}, {7, 1},
{4, 8}, {8, 4},
{5, 8}, {8, 5},
{2, 8}, {8, 2},
{7, 8}, {8, 7} };
int i;
clrscr();
puts("This is an example of Width Preferred Traverse of Gragh.\n");
for ( i = 1; i <= 8; i++ ) /*顶点结构数组初始化*/
{
head[i].vertex = i;
head[i].nextnode = NULL;
visited[i] = 0;
}
creategraph(node,20); /* 图信息转换,邻接表的建立 */
printf("The content of the graph's allist is:\n");
for ( i = 1; i <= 8; i++ )
{
printf(" vertex%d =>",head[i].vertex); /* 顶点值 */
ptr = head[i].nextnode; /* 顶点位置 */
while ( ptr != NULL ) /* 遍历至链表尾 */
{
printf(" %d ",ptr->vertex); /* 打印输出顶点内容 */
ptr = ptr->nextnode; /* 下一个顶点 */
}
printf("\n"); /* 换行 */
}
printf("The contents of BFS are:\n");
bfs(1); /* 打印输出遍历过程 */
printf("\n"); /* 换行 */
puts(" Press any key to quit...");
getch();
return 0;
}

图的深度优先遍历
/***************************************************************/
/* 图的深度优先遍历 */
/***************************************************************/
#include <stdlib.h>
#include <stdio.h>
struct node /* 图顶点结构定义 */
{
int vertex; /* 顶点数据信息 */
struct node *nextnode; /* 指下一顶点的指标 */
};
typedef struct node *graph; /* 图形的结构新型态 */
struct node head[9]; /* 图形顶点数组 */
int visited[9]; /* 遍历标记数组 */
/********************根据已有的信息建立邻接表********************/
void creategraph(int node[20][2],int num)/*num指的是图的边数*/
{
graph newnode; /*指向新节点的指针定义*/
graph ptr;
int from; /* 边的起点 */
int to; /* 边的终点 */
int i;
for ( i = 0; i < num; i++ ) /* 读取边线信息,插入邻接表*/
{
from = node[i][0]; /* 边线的起点 */
to = node[i][1]; /* 边线的终点 */
/* 建立新顶点 */
newnode = ( graph ) malloc(sizeof(struct node));
newnode->vertex = to; /* 建立顶点内容 */
newnode->nextnode = NULL; /* 设定指标初值 */
ptr = &(head[from]); /* 顶点位置 */
while ( ptr->nextnode != NULL ) /* 遍历至链表尾 */
ptr = ptr->nextnode; /* 下一个顶点 */
ptr->nextnode = newnode; /* 插入节点 */
}
}
/********************** 图的深度优先搜寻法********************/
void dfs(int current)
{
graph ptr;
visited[current] = 1; /* 记录已遍历过 */
printf("vertex[%d]\n",current); /* 输出遍历顶点值 */
ptr = head[current].nextnode; /* 顶点位置 */
while ( ptr != NULL ) /* 遍历至链表尾 */
{
if ( visited[ptr->vertex] == 0 ) /* 如过没遍历过 */
dfs(ptr->vertex); /* 递回遍历呼叫 */
ptr = ptr->nextnode; /* 下一个顶点 */
}
}
/****************************** 主程序******************************/
int main()
{
graph ptr; /* 边线数组 */
int node[20][2] = { {1, 2}, {2, 1},
{1, 3}, {3, 1},
{1, 4}, {4, 1},
{2, 5}, {5, 2},
{2, 6}, {6, 2},
{3, 7}, {7, 3},
{4, 7}, {4, 4},
{5, 8}, {8, 5},
{6, 7}, {7, 6},
{7, 8}, {8, 7} };
int i;
clrscr();
for ( i = 1; i <= 8; i++ ) /* 顶点数组初始化 */
{
head[i].vertex = i; /* 设定顶点值 */
head[i].nextnode = NULL; /* 指针为空 */
visited[i] = 0; /* 设定遍历初始标志 */
}
creategraph(node,20); /* 建立邻接表 */
printf("Content of the gragh's ADlist is:\n");
for ( i = 1; i <= 8; i++ )
{
printf("vertex%d ->",head[i].vertex); /* 顶点值 */
ptr = head[i].nextnode; /* 顶点位置 */
while ( ptr != NULL ) /* 遍历至链表尾 */
{
printf(" %d ",ptr->vertex); /* 印出顶点内容 */
ptr = ptr->nextnode; /* 下一个顶点 */
}
printf("\n"); /* 换行 */
}
printf("\nThe end of the dfs are:\n");
dfs(1); /* 打印输出遍历过程 */
printf("\n"); /* 换行 */
puts(" Press any key to quit...");
getch();
return 0;
}
我不爱小虎
2008-12-25
知道答主
回答量:21
采纳率:0%
帮助的人:0
展开全部
7.算术表达式求值

#include <stdio.h>
void main()
{
int a,b,c,d,e,f,g,m;
printf("1,两数之和\n:");
printf("2,两数之差\n:");
printf("3,两数之积\n:");
printf("4,两数之商\n:");
printf("5,两数之余\n:");
scanf("%d",&m);
which(m)
{
1,scanf("input a b:%d,%d",&a,&b);
c=a+b;
printf("%d",c);
break;
2,scanf("input a b:%d,%d",&a,&b);
d=a-b;
printf("%d",d);
break;
3,scanf("input a b:%d,%d",&a.&b);
e=a*b;
printf("%d",e);
break;
4,scanf("input a b:%d,%d",&a,&b);
f=a/b;
printf("%d",f);
break;
5,scanf("input a b:%d,%d",&a,&b);
g=a%b;
printf("%d",g);
break;
}
}

2.集合问题
集合的和:用"&&"表示
集合的交集:用"||"表示
集合的补集:用"!"表示

#include<stdio.h>
void main()
{
char m[10],n[10],a[x],b[y],c[z];
int x,y,z,d,i,j;
printf("1,两个集合的和\n:");
printf("2,两个集合的交集\n:");
printf("1,两个集合的补集\n:");
scanf("%d",&d);
which(d)
{
1,scanf("input:%s,%s",&m[i].&n[j]);
a[x]=m[i]&&n[j];
printf("%s",&a[x]);
break;
2,scanf("input:%s,%s",&m[i].&n[j]);
b[y]=m[i]||n[j];
printf("%s",&b[y]);
break;
3,scanf("input:%s,%s",&m[i].&n[j]);
c[z]=m[i]!n[j];
printf("%s",&c[z]);
break;
}
}

祝福你可以通过考试.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
wodeshangdime
2008-12-25 · TA获得超过143个赞
知道答主
回答量:121
采纳率:0%
帮助的人:0
展开全部
咯咯 您好
我来选择其中的比较简单的做一下解答吧.
2.集合问题
集合的和:用"&&"表示
集合的交集:用"||"表示
集合的补集:用"!"表示
7.算术表达式求值
+ - * / %
举例说明下:
#include <stdio.h>
main()
{
int a,b,sum,diff,mul,div,rem;
printf("input two numbers:");
scanf("%d%d",&a,&b);
sum=a+b;
diff=a-b;
mul=a*b;
div=a/b;
rem=a%b;
printf("两数之和:%d\n两数之差:%d\n两数之积:%d\n两数之商:%d\n余数:%d\n",sum,diff,mul,div,rem);
}
咯咯 衷心祝福你可以通过考试.
咯咯...
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
星点之火
2008-12-25 · 超过14用户采纳过TA的回答
知道答主
回答量:51
采纳率:0%
帮助的人:45.4万
展开全部
7算术表达式求值问题:
#include<stdio.h>
#include<math.h>
main()
{
int m=1;
float a,b,c;
char op;
printf("Please input a op b:\n");
scanf("%f%c%f",&a,&op,&b);
switch(op)
{
case '+':c=a+b;break;
case '-':c=a-b;break;
case '*':c=a*b;break;
case '/':c=a/b;break;
default:m=0;
}
switch(m)
{
case 1:printf("%f%c%f=%f\n",a,op,b,c);break;
case 0:printf("Enter error\n");break;
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
magic_knife
2008-12-25 · TA获得超过848个赞
知道小有建树答主
回答量:2882
采纳率:0%
帮助的人:972万
展开全部
后面的题多是学完了整本数据结构才考的吧
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(3)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式