#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
#include "shape.h"
#include "circle.h"
#include "rectangle.h"
void MainMenu()
{
cout<<"1、添加圆形"<<endl
<<"2、添加矩形"<<endl
<<"3、显示所有图形"<<endl
<<"4、退出"<<endl;
cout<<"请输入您的选择:";
}
void readFile(char fileName[])
{
Rectangle r,r_sum;
Circle c,c_sum;
ifstream in(fileName,ios::in|ios::binary);
if(!in)
{
cout<<"文件打开错误!"<<endl;
exit(1);
}
if(strcmp(fileName,"circle.dat")==0)
{
while(in.read((char *)&c,sizeof(c))!=NULL)
{
c.show();
c_sum+=c;
}
cout<<"\t\t\t\t总的半径为:"<<c_sum.r<<endl;
}
else
{
while(in.read((char *)&r,sizeof(r))!=NULL)
{
r.show();
r_sum+=r;
}
cout<<"\t\t\t\t总的长度:"<<r_sum.length<<endl
<<"\t\t\t\t总的宽度:"<<r_sum.width<<endl;
}
in.close();
}
void main()
{
int choice;
Circle c;
Rectangle r;
while(1)
{
system("cls");
MainMenu();
cin>>choice;
if(choice==1)
{
c.input();
c.writeFile();
}
else if(choice==2)
{
r.input();
r.writeFile();
}
else if(choice==3)
{
readFile("circle.dat");
readFile("rect.dat");
}
else if(choice==4)
{
break;
}
else
{
cout<<"输入了错误的编号"<<endl;
}
cout<<"按Enter键回到主菜单.......";
cin.get();
cin.get();
}
}
图形管理软件
需积分: 0 192 浏览量
2008-07-27
02:03:28
上传
评论
收藏 268KB RAR 举报
ajty288mdyangqi
- 粉丝: 0
- 资源: 1
最新资源
- mosquitto-2.018-install-windows-x64
- FTPServer FTP 服务器,绿色免安装,单文件
- 梦畅语音点名软件,上课点名
- 利用ADNI数据集和标签,在tensorflow框架上使用tensorlayer接口,通过架构u-net实现海马体的分割
- Kutools for Word v9.0 office word 插件
- 修复Windows 10 LTSC 2021资源占用率高
- Hash工具,小巧绿色hash校验工具,免费hash工具
- 重启进行BIOS快捷方式,不需要开机按BIOS键
- 鸭子开车记(儿童绘本)
- 威纶通触摸屏编程软件Easy builder pro V6.09.01.556安装包(2024.04).txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0