OJ比较大小-类模板
来源:互联网 发布:activity之间传递数据 编辑:程序博客网 时间:2024/05/16 15:46
/** 程序的版权和版本声明部分:* Copyright (c) 2013, 烟台大学计算机学院* All rights reserved.* 文件名称:test.cpp* 作 者:任子仪* 完成日期:2014年 5月 28日* 版 本 号:v12.1* 输入描述:无* 问题描述:。* 程序输出:* 问题分析:略* 算法设计:略*/#include <iostream>#include <iomanip>using namespace std;template<class numtype>class Compare{public: Compare(numtype a,numtype b); numtype max(); numtype min();private: numtype x,y;};template<class numtype>Compare<numtype>::Compare(numtype a,numtype b){ x=a; y=b;}template<class numtype>numtype Compare<numtype>::max(){ return (x>y)?x:y;}template<class numtype>numtype Compare<numtype>::min(){ return (x<y)?x:y;}int main(){ int i1,i2; cin>>i1>>i2; Compare<int> cmp1(i1,i2); cout<<cmp1.max()<<" "<<cmp1.min()<<endl; float f1,f2; cin>>f1>>f2; Compare<float> cmp2(f1,f2); cout<<setiosflags(ios::fixed); cout<<setprecision(2); cout<<cmp2.max()<<" "<<cmp2.min()<<endl; char c1,c2; cin>>c1>>c2; Compare<char> cmp3(c1,c2); cout<<cmp3.max()<<" "<<cmp3.min()<<endl; return 0;}
示例图片;
心得体会:表示模板从来都没学会啊。。。。。。。。做oj,发现了很大自己以前不会的。加油
0 0
- OJ比较大小-类模板
- OJ比较大小-类模板
- 17周 oj 比较大小 类模板
- △【OJ】---Q---比较大小-类模板
- YTU-OJ- 比较大小-类模板
- OJ——比较大小-类模板
- 2015年第十四周oj刷题:比较大小-类模板
- 比较大小-类模板
- 比较大小-类模板
- OJ 比较大小 类模版
- 第十五周oj刷题——Problem I: C++ 习题 比较大小-类模板
- YTU-OJ-Problem L: 熟悉题型——自由设计(比较大小-类模板)
- ACM~比较大小-类模板
- ACM--类模板 比较大小
- 2437比较大小类模板
- YTUOJ-比较大小-类模板
- oj比较大小
- 比较大小 ——类模板
- list加入一个map,改变map值再加入一次
- linux下IPTABLES配置详解
- TCP 的那些事儿(下)
- 备战“软考”之组成原理
- POJ1019-Number Sequence
- OJ比较大小-类模板
- 给Arduino打电话 — Twilio云通讯
- AJAX的相关使用方法
- Nginx负载均衡
- android使用ffmpeg
- 浅析分布式数据库
- iOS run loop NSRunloop
- 线性表写一元二次方程组
- 字符编码详解——彻底理解掌握编码知识,“乱码”不复存在