一份测试卷,大家做做看(2)

Jianli2004 2005-01-18 10:42:11
3.请完成以下集合类模板的设计,集合类对象的创建及使用。
#include<iostream.h>
const maxcard=20;
template<class T>class set{
T elems[maxcard];
int card;
public:
set( ){______1______;}
friend bool operator&(T,set);
friend bool operator==(set,set);
friend bool operator!=(set,set);
friend ____2____ operator+(set,set);
friend set operator+(set,T);
friend set operator-(set,T);
friend set operator*(set,set);
friend ostream&operator<<(_____3_____,const set&s){
for(int i=0;i<s.card;i++)out<<s.elems[i]<<" ";
return out;}
};
template<class T>bool operator&(T e ,set<T> s){
for(int i=0;i<s.card;i++)
if(s.elems[i]==e)
return true;
return _____4_____;}
template<class t>bool operator==(set<t> s1,set<t> s2){
if(s1.card!=s2.card)return false;
for(int i=0;i<s1.card;i++)
if(!(s1.elems[i]&s2))return false;
return true;}
template<class t>bool operator!=(set<t> s1,set<t> s2)
{ return !(s1==s2)?true:false;}
template<class t>set<t> operator+(set<t> s,t e)
{____5_____ res=s;
if(s.card<maxcard)
if(!(e&s))res.elems[res.card++]=e;
return res;}
template<class t>set<t> operator+(set<t> s1,set<t> s2)
{set<t> res=s1;
for(int i=0;i<s2.card;i++)
res=res+s2.elems[i];
return ___6___;}
template<class t>set<t> operator-(set<t> s,t e)
{set<t> res=s;
if(!(e&s))return res;
for(int i=0;i<s.card;i++)
if(s.elems[i]==e)
for(;i<s.card-1;i++)
res.elems[i]=res.elems[i+1];
____7____;
return res;}
template<class t>set<t> operator*(set<t> s1,_______8_______){
set<t> res;
for(_____9_____;i<s1.card;i++)
for(int j=0;j<s2.card;j++)
if(s1.elems[i]==s2.elems[j])
{ res.elems[res.card++]=s1.elems[i];break;}
return res;}
void main( ){
set<int> ______10______;
set<double> s4,s5;
for(int i=0;i<10;i++)
s1=s1+i;
s2=s1;
for(i=0;i<2;i++)
s1=s1-i;
s3=s1*s2;
cout<<s3<<endl;
for(i=0;i<5;i++)
s4=s4+3.5*i;
s5=s4+s5;
cout<<s5<<endl;
}
4.设计一个学生类,其属性有学号、姓名、性别、年龄和计算机原理成绩,并定义相应操作,重载析取符( >> )和插入符( << )以支持I/O操作。然后在main函数中定义学生对象数组,对于学生对象数组从磁盘文件“student.txt” 进行输入,最后以学号n为参数在数组中查找学号为n的学生,并显示该生的全部信息。


...全文
324 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
pcboyxhy 2005-01-24
  • 打赏
  • 举报
回复
我们学校连那些东西都没有
无招胜有招
look01 2005-01-24
  • 打赏
  • 举报
回复
又是学生类,要不就是图书管理系统,讨厌死了,该死的大学教育!请以后不要再在这里发了。
qufan 2005-01-24
  • 打赏
  • 举报
回复
mark too
请版主鉴定吧,呵呵
junnyfeng 2005-01-24
  • 打赏
  • 举报
回复
mark
Jianli2004 2005-01-24
  • 打赏
  • 举报
回复
C++ 版人气真差,没有能人么?
Jianli2004 2005-01-24
  • 打赏
  • 举报
回复
C++ 版人气真差,没有能人么?
iCherish 2005-01-19
  • 打赏
  • 举报
回复
是什么书上的一道习题。。
我见过。。
Jianli2004 2005-01-19
  • 打赏
  • 举报
回复
有兴趣的,可以试试,据说能测基本情况
Jianli2004 2005-01-19
  • 打赏
  • 举报
回复
谢谢各位的辛苦劳动。分是不会少的
是一个MM来问我的,我实在没有时间去做
代码是COPY来的,格式变了,所以看的不好

一题100分
希望有时间和能力的朋友出手


薄荷,在吗?

pcboyxhy 2005-01-19
  • 打赏
  • 举报
回复
显然是作业题
csdboy 2005-01-19
  • 打赏
  • 举报
回复
找骂来了
bill_li 2005-01-19
  • 打赏
  • 举报
回复
up
idau7 2005-01-18
  • 打赏
  • 举报
回复
怀疑作业..
somedummy 2005-01-18
  • 打赏
  • 举报
回复
作业……
zhangfjj 2005-01-18
  • 打赏
  • 举报
回复
考试题?
[14本经典Android开发教程] 2 Android开发手册 API函数详解 一 TextView的API 1 1 结构 java lang Object android view View android widget TextView 直接子类: Button CheckedTextView Chronometer DigitalClock EditText 间接子类: AutoCompleteTextView CheckBox CompoundButton ExtractEditText MultiAutoCompleteTextView RadioButton ToggleB utton 已上传1本: [14本经典Android开发教程] 1 Android开发从入门到精通 稍后上传剩余12本 http: download csdn net detail cleopard 8355245 @更多@ http: cleopard download csdn net 福利 http: xuemeilaile com @更多@ http: download csdn net user cleopard album 17份软件测试文档 http: download csdn net album detail 1425 13份WPF经典开发教程 http: download csdn net album detail 1115 C#资料合辑二[C#桌面编程入门篇] http: download csdn net album detail 957 C#资料合辑一[C#入门篇] http: download csdn net album detail 669 [Csharp高级编程 第6版 ] 共8压缩卷 http: download csdn net album detail 667 10个[精品资源]Java学习资料合辑[一] http: download csdn net album detail 663 10个C#Socket编程代码示例 http: download csdn net album detail 631 6份GDI+程序设计资源整合[全零分] http: download csdn net album detail 625 2014年移动游戏行业数据分析 http: download csdn net detail cleopard 8340331 一文读懂2014年全球互联网广告新生态 http: download csdn net detail cleopard 8340303">[14本经典Android开发教程] 2 Android开发手册 API函数详解 一 TextView的API 1 1 结构 java lang Object android view View android widget TextView 直接子类: Button CheckedTextView Chronometer DigitalClock EditText 间接子类: AutoCompleteTextView CheckBox CompoundBu [更多]
[14本经典Android开发教程] 9 Android2 3用户手册 已上传8本: [14本经典Android开发教程] 1 Android开发从入门到精通 http: download csdn net detail cleopard 8355245 [14本经典Android开发教程] 2 Android开发手册 API函数详解 http: download csdn net detail cleopard 8374487 [14本经典Android开发教程] 3 Android SDK 中文开发文档 http: download csdn net detail cleopard 8380429 [14本经典Android开发教程] 4 Android应用程序开发36技 http: download csdn net detail cleopard 8380495 [14本经典Android开发教程] 5 linux Android基础知识总结 http: download csdn net detail cleopard 8380529 [14本经典Android开发教程] 6 Android驱动开发入门及手机案例开发分析教程 http: download csdn net detail cleopard 8388019 [14本经典Android开发教程] 7 Android编程入门教程 http: download csdn net detail cleopard 8388043 [14本经典Android开发教程] 8 Linux内核阅读心得体会 http: download csdn net detail cleopard 8391591 剩余8本稍后上传 @或直接从这里寻找@ http: download csdn net user cleopard album @更多@ http: cleopard download csdn net 福利 http: xuemeilaile com 17份软件测试文档 http: download csdn net album detail 1425 13份WPF经典开发教程 http: download csdn net album detail 1115 C#资料合辑二[C#桌面编程入门篇] http: download csdn net album detail 957 C#资料合辑一[C#入门篇] http: download csdn net album detail 669 [Csharp高级编程 第6版 ] 共8压缩卷 http: download csdn net album detail 667 10个[精品资源]Java学习资料合辑[一] http: download csdn net album detail 663 10个C#Socket编程代码示例 http: download csdn net album detail 631 6份GDI+程序设计资源整合[全零分] http: download csdn net album detail 625 2014年移动游戏行业数据分析 http: download csdn net detail cleopard 8340331 一文读懂2014年全球互联网广告新生态 http: download csdn net detail cleopard 8340303">[14本经典Android开发教程] 9 Android2 3用户手册 已上传8本: [14本经典Android开发教程] 1 Android开发从入门到精通 http: download csdn net detail cleopard 8355245 [14本经典Android开发教程] 2 Android开发手册 A [更多]

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧