cpp 8.14
来源:互联网 发布:手机卡没办法收到网络 编辑:程序博客网 时间:2024/06/16 01:19
8.14
#include<iostream>template <typename T>void ShowArray(T arr[], int n);template<typename T>void ShowArray(T *arr[], int n);struct debts{char name[50];double amount;};int main(){using namespace std;int things[6] = { 13,31,103,301,310,130 };struct debts mr_E[3] ={{"Ima Wolfe", 2400.0},{"Ura Foxe", 1300.0},{"Iby stout", 1800.0}};double * pd[3];for (int i = 0; i < 3; i++)pd[i] = &mr_E[i].amount;cout << "Listing Mr. E's counts of things:\n";ShowArray(things, 6);cout << "Listing Mr E's debts:\n";ShowArray(pd, 3);system("pause");return 0;}template<typename T>void ShowArray(T arr[], int n){using namespace std;cout << "template A\n";for (int i = 0; i < n; i++)cout << arr[i] << ' ';cout << endl;}template <typename T>void ShowArray(T * arr[], int n){using namespace std;cout << "template B\n";for (int i = 0; i < n; i++)cout << *arr[i] << ' ';cout << endl;}
8.15
#include<iostream>\template<class T>T lesser(T a, T b){return a < b ? a : b;}int lesser(int a, int b){a = a < 0 ? -a : a;b = b < 0 ? -b : b;return a < b ? a : b;}int main(){using namespace std;int m = 20;int n = -30;double x = 15.5;double y = 25.9;cout << lesser(m, n) << endl;cout << lesser(x, y) << endl;cout << lesser<>(m, n) << endl;cout << lesser<int>(x, y)<<endl;system("pause");return 0;}
0 0
- cpp 8.14
- cpp
- CPP
- CPP
- cpp
- cpp
- CPP
- CPP
- ClientSockThread.cpp&&ClientUrlThread.cpp
- cpp调用其他cpp
- ex34a.cpp&&ex34aDoc.cpp&&ex34aView.cpp
- MainFrm.cpp&&ServerThread.cpp&&SheetConfig.cpp
- CPP thread
- cpp->html
- CFaderWnd.cpp
- PasswordReminder.cpp
- object.cpp
- CmdTarget.cpp
- 16 - 12 - 14 红黑树(一)(性质、插入)
- Java Collection Stack
- 卸载 yum 安装的软件
- 前端开发工程化探讨
- 网络连接状态判断
- cpp 8.14
- [Google Guava] 1.4排序: Guava强大的”流畅风格比较器”
- C#学习日记-初级-2.进入C#编程
- eclipse中的.project 和 .classpath文件的具体作用
- LINQ中Aggregate的用法
- 新手 自定义SlidingMenu控件
- Integer和int的区别
- CSS3图形自绘合集
- Python爬虫 正则表达式