网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
若有以下程序: include using namespace std; template T min(T x,T y) {i

若有以下程序:

include <iostream>

using namespace std;

template <class T>

T min(T x,T y)

{

if(x<y)

return x;

else

return y;

}

int main()

{

int n1=2,n2=10;

double d1=1.5;d2=5.6;

cout<<min(n1,n2)<<",";

cout<<min(d2,d2)<<end1;

return 0;

}

程序运行后的输出结果是【 】。


参考答案

更多 “ 若有以下程序: include using namespace std; template T min(T x,T y) {i 若有以下程序:include <iostream>using namespace std;template <class T>T min(T x,T y){if(x<y)return x;elsereturn y;}int main(){int n1=2,n2=10;double d1=1.5;d2=5.6;cout<<min(n1,n2)<<",";cout<<min(d2,d2)<<end1;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

考题 有如下程序: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:: ond1; retum0; }执行后的输出结果是______ 。A.41,41B.23,23C.13,42D.42,23

考题 阅读下列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 include template class TA 以下程序的运行结果是______。include<iostream.h>include<math.h>template<class T>class TAdd//定义类模板TAdd,T为类型{Tx,y;public:TAdd (Ta,Tb) {x=a,y=b;) //构造函数Tadd() { retum x+y;}//成员函数};void main( ){TAdd<int>A (5,6);

考题 下面程序的输出结果是()。includeusing namespace std;templateT max(T x,T 下面程序的输出结果是( )。 #include<iostream> using namespace std; template<class T> T max(T x,T y) { return(x>= y ? x:y);} template<class T> T max(T x,T y,T z) { T t; t=(x>=y ? x:y); return(t>=z ? t:z); } void main(){ int x = 10,y=18,maxi; float a = 1.2,b = 3.2,c = 2,max2; max1 = max(x,(int)c); max2 = max(a,b,(float)y); cout<<maxi<<endl; cout<<max2<<endl;A.18 3.2B.10 18C.10 3.2D.编译出错

考题 请选出以下程序的输出结果_______。 includesub(int*s,inty){ static int t=3,y=s[t];t 请选出以下程序的输出结果_______。 #include<stdio.h> sub(int*s,inty) { static int t=3, y=s[t];t-; } main() { int a[]={1,2,3,4},i,x=0; for(i=0;i<4;i++){ sub(a,x);printf("%d",x);} printf("\n"); }A.1234B.4321C.0D.4444

考题 以下类模板成员函数定义正确的是: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