1#include <iostream>2 3 using namespacestd;4 5template<classT>voidIndexintn,t num1[]) {6 for(intI=0; i<n;i++)7 {8cout<<"Index"<<i<<Endl;9Cin>>Num1[i];Ten }; One } A -Template <classT>voidPrint1 (intn,t num1[]) { - for(intI=0; i<n;i++) the { -cout<<i<<" "<<num1[i]<<Endl; - }; - } + -template<classT>voidPrint2 (intn,t num1[]) { + for(intI=0; i<n;i++) A { atcout<<i<<" "<<num1[i]<<Endl; - }; - } - -template<classT>voidRankintn,t num1[]) { - T K; in for(intI=0; i<n-1; i++) - { to for(intj=i+1; j<n;j++){ + if(num1[i]>Num1[j]) - { thek=Num1[i]; *num1[i]=Num1[j]; $num1[j]=K;Panax Notoginseng - }; the } + }; A } the + intMain () - { $cout <<"Hello world!"<<Endl; $ intN; - intnum1[ -]; - floatnum2[ -]; the Doublenum3[ -]; -cout<<"Total Arry"<<Endl;WuyiCin>>N; theIndex (N,NUM1); Print1 (N,NUM1); Rank (N,NUM1); cout<<Endl; Print2 (N,NUM1); -Index (N,NUM2); Print1 (N,NUM2); Rank (n,num2); cout<<Endl; Print2 (n,num2); WuIndex (N,NUM3); Print1 (N,NUM3); Rank (N,NUM3); cout<<Endl; Print2 (N,NUM3); - return 0; About}
"C + +" function template operations for different types of arrays