找不出問題
#include"stdlib.h" #include"iostream" using?namespace?std; namespace?A { ?Getmaxormin(int?a[],int?n,bool?ismax) ?{ ??int?temp=a[0]; ??for(int?i=1;i<n;i++) ??{ ???if(ismax) ???{ ????if(temp<a[i]) ?????temp=a[i]; ???} ???else ???{ ????if(temp>a[i]) ?????temp=a[i];? ???} ??} ??return?temp; ?} } int?main(void) { ?int?a[5]={5,3,4,6,2,}; ?bool?ismax=false; ?cout<<"請輸入你要找的是最大值(1)還是最小值(0)"<<endl; ?cin>>ismax; ?cout<<A::Getmaxormin(a,5,ismax)<<endl; ?system("pause");? ?return?0; }
2017-11-25
確實找不出問題,我復制粘貼你的代碼,運行并沒有問題。要么是你的編譯器出了問題