1.作业内容(1分)
ADT Rational{
数据对象:D={e1,e2|e1,e2都是Elemtype类型}
数据关系:R={<e1,e2>}
基本操作:
Builtration(&T,e1,e2)
Destroyration(&T)
Getration(i,&e1,&e2)
Modifyration(i,&e1,&e2)
Add(T1,T2,&T3)
Minus(T1,T2,&T3)
Multiply(T1,T2,&T3)
Division(T1,T2,&T3)
}ADT Rational
2.数据结构、函数说明(2分)截图展示你的头文件。头文件代码务必加入注释。


3.代码实现说明(4分)截图展示每个函数代码。简要说明做法。建议用C++语法:cin,cout,引用参数&,new,delete
1.e1,e2的返回

2.分配存储空间

3.销毁

4.改变e1,e2的值

5.实现T1和T2的加减乘除(4个函数)

5.结果展示(2分)
1.改变T1和T2的值,并返回查看它们的分子分母值

2.实现T1和T2的加减乘除

6.总结(1分)
1.逻辑结构包括线性结构,树形结构,图形结构;
2.存储结构包括顺序存储结构,链式存储结构,索引存储结构和散列存储结构;
3.抽象数据类型的基本描述格式:
ADT 抽象数据类型名
{
数据对象:数据对象的声明
数据关系:数据关系的声明
基本运算:基本运算的声明
}’
4.C++简单语法
- 1.使用cin和cout必须在程序开头增加两行:#include using namespace std;
- 2.输入cin>>a>>b>>c;
- 3.输出cout<<a<<"\\n"<<b<<endl;
- 4.发现&(引用符号)非常好用,当没有指向的指针传参进入函数进行空间申请时,用int * &T来传参才行,不能用int *T;
- 5.感觉空间和时间复杂度的分析还不很明白,而且它们非常重要,所以会尽力弄懂的;