#include<iostream>#include<string>#include<cctype>usingnamespace std;voidto_up(string& a);intmain(){
string a;
cout <<"Enter a string (q to quit):";while(getline(cin, a)&& a !="q"){to_up(a);
cout <<a<<endl;
cout <<"Enter next string:(q to quit):";}}voidto_up(string& a){for(int i =0; i < a.size(); i++){
a[i]=toupper(a[i]);}}
#include<iostream>usingnamespace std;#include<cstring>;structstringy{char* str;int ct;};voidset(stringy& first,constchar* test);voidshow(const stringy& first,int num=1);voidshow(constchar* first,int num =1);intmain(){
stringy beany;char testing[]="Reality isn't what it used to be.";set(beany, testing);show(beany);show(beany,2);
testing[0]='D';
testing[1]='u';show(testing);show(testing,3);show("Done!");return0;}voidset(stringy& first,constchar* test){
first.str =newchar[strlen(test)+1];strcpy_s(first.str,strlen(test)+1,test);}voidshow(const stringy& first,int num){
cout << first.str<<endl;while(num >1){
cout << first.str << endl;
num--;}}voidshow(constchar* first,int num){
cout << first << endl;while(num >1){
cout << first << endl;
num--;}}
#include<iostream>usingnamespace std;template<typenameT>
T Max5(const T* array);intmain(){int test1[5]={1,3,5,7,9};double test2[5]={10.0,20.0,15.0,12.0,30.0};
cout <<"The max of int array is: "<<Max5(test1)<< endl;
cout <<"The max of double array is: "<<Max5(test2)<< endl;return0;}template<typenameT>
T Max5(const T* array){
T tempt = array[0];for(int i =0; i <5; i++){if(array[i]> tempt)
tempt = array[i];}return tempt;}
#include<iostream>#include<cstring>usingnamespace std;template<typenameT>
T maxn(T *arr,int n);template<>constchar*maxn(constchar*str[],int n);intmain(){int test1[6]={1,3,5,7,9,11};double test2[4]={10.0,20.0,15.0,12.0};constchar*test3[5]={"123","12345","123456","abcdefg","xio"};
cout <<"The max of int array is: "<<maxn(test1,6)<< endl;
cout <<"The max of double array is: "<<maxn(test2,4)<< endl;
cout <<"The max of string array is: "<<maxn(test3,5)<< endl;return0;}template<typenameT>
T maxn(T *arr,int n){
T temp = arr[0];for(int i =0; i < n; i++){if(temp < arr[i]){
temp = arr[i];}}return temp;}template<>constchar*maxn(constchar*str[],int n){constchar*temp =*str;for(int i =1; i < n; i++){if(strlen(temp)<strlen(str[i])){
temp = str[i];}}return temp;}
#include<iostream>template<typenameT>
T SumArray(T arr[],int n);template<typenameT>
T SumArray(T *arr[],int n);structdebts{char name[50];double amount;};intmain(){usingnamespace std;int things[6]={13,31,103,301,310,130};
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 total of things:"<< endl;
cout <<SumArray(things,6)<< endl;
cout <<"Listing Mr. E's total of debts:"<< endl;
cout <<SumArray(pd,3)<< endl;return0;}template<typenameT>
T SumArray(T arr[],int n){usingnamespace std;double sum =0.0;for(int i =0; i < n; i++){
sum += arr[i];}return sum;}template<typenameT>
T SumArray(T *arr[],int n){usingnamespace std;double sum =0.0;for(int i =0; i < n; i++){
sum +=*arr[i];}return sum;}