Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<vector>
- #include<iostream>
- using namespace std;
- template<class Type>
- Type Sum(vector<Type> &A) {
- Type S = 0;
- for (auto a : A) {
- S += a;
- }
- return S;
- }
- template<class Type>
- Type Max(vector<Type> &A) {
- Type S = A[0];
- for (int i = 1; i < A.size();i++) {
- if(A[i]>S)
- S=A[i];
- }
- return S;
- }
- int main()
- {
- vector<int> V = { 1,2,3,4,5,6,7,8,9 };
- vector<double> VD{ 1.1,2.2,3.3,4.4,5.5 };
- cout << Sum(V) << endl;
- cout << Sum(VD) << endl;
- cout << Max(V) << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement