主要代码
/****************************************************
@title: 数据结构实验
@name:<试验> 一元多项式简单计算器
@object:
[实验目的]
单链表的存储结构及其基本操作的实现
[实验提示]
1. 在linklist.h中实现单链表的基本操作
2.在Polynomial.h中实现了一元多项式的基本操作
3.在Polynomial.h中编写代码,进行测试
4.在MutualPlat.h中编写一交互式的运行平台
@include:
ds.h [*]
单链表的实现
@author: wangheng
@date: 3 / 4 / 2017
***************************************************/
#define Number 2.0
#include <stdio.h>
#include <stdlib.h>
#include "MutualPlat.h"
int main()
{
printf("是否进行运算(Y/N): ");
char command;
polynomial P1;
polynomial P2;
read(command);
while(command == 'Y')
{
run();
printf("是否进行运算(Y/N): ");
readM(command);
}
return 0;
}
#ifndef MUTUALPLAT_H_INCLUDED
#define MUTUALPLAT_H_INCLUDED
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "ds.h"
#include "Polynomial.h"
void input (polynomial& P)
{
printf("\n输入一个一元多项式的各项系数和指数[当输入的系数和指数为:(0 0) 时,输入结束]\n");
CreatPolyn(P);
PrintPolyn(P);
printf("一元多项式的项数: %d\n",PolynLength(P));
}
void CaculateMenu()
{
printf("选择你想进行的运算方法:[A](add),[S](substract),[M](multiply),\n[D](Derivative),[C](Calculus)---");
}
Status GetCommand(char& way)
{
printf("\n运算方法为:");
readM(way);
printf("\n");
return OK;
}
void run( )
{
char way;
polynomial P1;
polynomial P2;
CaculateMenu();
GetCommand(way);
switch(way)
{
case 'A' :
case 'a':
input(P1);
input(P2);
AddPolyn(P1,P2);
printf("打印输出和:\n");
PrintPolyn(P1);
break;
case 'S' :
case 's':
input(P1);
input(P2);
SubtractPolyn(P1,P2);
printf("打印输出差:\n");
PrintPolyn(P1);
break;
case 'M' :
case 'm':
input(P1);
input(P2);
MultiplyPolyn(P1,P2);
<