有如下程序: include using namespace std; template T total(T * data) 有如下程序:include<iostream>using namespace std;template<typename T>T total(T * data) {T s=0;While(* data)s+ = *data + +;return s;}int main(){int x[]:{2,4,6,8, 10, 12, 14, 16, 18};cout<<total(x);

有如下程序: include using namespace std; template T total(T * data)

有如下程序:

include<iostream>

using namespace std;

template<typename T>

T total(T * data) {

T s=0;

While(* data)s+ = *data + +;

return s;

}

int main(){

int x[]:{2,4,6,8, 10, 12, 14, 16, 18};

cout<<total(x);


相关考题:

执行下面程序输出的是【】。 include using namespace std;template T tot 执行下面程序输出的是【 】。include <iostream>using namespace std;template <typename T>T total(T *data){Ts=0;while( *data) s+=*data++;return s;}int main(){int s[]={1,3,5,7,0,2,4,6,8};cout<<total(s);return 0;}

有如下程序:includevoid fun(intx, int y){int t=x; x=y; y=t;}int main(){int 有如下程序: #include<iostream> void fun(intx, int y){int t=x; x=y; y=t;} int main() { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::end1; return 0; } 执行后的输出结果是( )。A.42,42B.23,23C.23,42D.42,23

下列程序的输出结果是【】 includeusing namespace std; template T total 下列程序的输出结果是【 】include<iOStream>using namespace std;template <typename T>T total (T*datA){T s=0;while(*datA){s+=*data++;}return s;}int main(){int x[]={2,4,6,8,0,12,14,16,18};cout<<total(x)<<end1;return 0;}

阅读下列C++程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】设单链表的结点类和链表类的定义如下,链表不带有表头结点。请填空:include<iostream.h>include<assert.h>template<class T>class List;template<class T>class ListNOde{friend (1);private:T data;ListNode<T> *link;public:ListNode():link(NULL)()ListNOde(const T item,ListNOde<T>*next=NULL):data(item),link(next){}};template<class T>class List{private:ListNode<T>*first;void createList(T A[],int n,int i,ListNOde<T>*p);void printList(ListNOde<T>*p);public:List();~List();friend ostream operator<<(ostream ost,List<T>L);friend istream operator>>(istream ist,List<T>L);};template<class T>istream operator>>(istream ist,List<T>1){int i,n; ist>>n;T A[n];for(i=0;i<n;i++) (2);createList(A,n,0,first);}template<class T>void List<T>::createList(TA[],int n,int i,ListNOde<T>* p){//私有函数:递归调用建立单链表if(i==n)p=NULL;else{p=new ListNode<T>(A[i]);assert(p !=NULL);createList((3));}}template<class T>ostream operator<<(ostream ost,List<T> L){(4);}template<class T>void List<T>::printList(ostream ost,ListNode<T>*p){if(p!=NULL){ost<<p->data;(5);}}

有如下程序: include void fun(intx,int y){int t=x;x=y;y=t;} int ma 有如下程序: #include<iostream> void fun(intx,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42}; fun(a[1],a[0]; std::cout<<a[0]<<","<<a[1]<<std::ndl; return 0; } 执行后的输出结果是A.42,42B.23,23C.23,42D.42,23

有如下程序:include void fun(int x, int y){int t=x;x=y;y=t;}int main (){int 有如下程序: #include <iostream> void fun(int x, int y){int t=x;x=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行后的输出结果是A.42,42B.23,23C.23,42D.42,23

如下程序的输出结果是includevoid fun(int x=y;y=t;}int main(){in 如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }A.42,42B.23,23C.23,42D.42,23

程序的结果为______。include"iostream.h" template T total(T*data) { Ts=0; while( 程序的结果为______。include"iostream.h"template<typename T>T total(T*data){Ts=0;while(*data){S+=*data++;}return S;}int main(){int x[]={2,4,6,8,0,12,14,16,18};cout<<total(x);retum 0;cout<<endl;}

以下类模板成员函数定义正确的是:A.template<class T> auto MyClass::foo(){ std::cout << "Aloha World!"<<std::endl; }#B.template<class T> auto MyClass<T>::foo(T t){ std::cout << t << std::endl; }#C.void MyClass<T>::foo(T t){ std::cout << t << std::endl; }#D.template<class T, int S> S MyClass<T, S>::foo(T t, S s){ s = static_cast<S>(t); std::cout << s << std::endl; retu