為什么運行不出來,找不到文件
#include<stdlib.h>? ?//有system(pause)就要有這個
#include<iostream>? //有cin和cout就要有這個
using namespace std;
int getMaxOrMin(int*arr,int count,bool isMax)
?{
int temp=arr[0];
for(int i=1;i<count;i++)
{
if(isMax);
{
if(temp<arr[i]);
{
temp=arr[i];
}
}
else
{
if(temp>arr[i]);
{
temp=arr[i];
}
}
return temp;
}
?}
int main(void)
{
int arr1[4]={3,5,7,9};
bool isMax=false;
cin>>isMax;
cout<<getMaxOrMin<<endl;
system("pause");
return 0;
}
2020-02-28
2020-02-20
上面那位兄弟已經將你的問題解決了。我只是進行一下修飾,僅做參考:
修改main函數:
int main(void)
{
? ??
? ? int arr1[4];
? ? cout << "請輸入4個需要判斷的數字: " << endl;
? ? for (int i = 0; i < 4; i++)
? ? ? ? cin >> arr1[i];
? ? bool isMax = false;
? ? cout << "輸出最小值輸入:0" << endl;
? ? cout << "輸出最大值輸入:1" << endl;
? ? cin >> isMax;
? ? cout << getMaxOrMin(arr1,4, isMax) << endl;
? ? system("pause");
? ? return 0;
}
2020-01-19
把這里“cout<<getMaxOrMin<<endl;”改成“? ? cout<<getMaxOrMin(arr1,4,isMax)<<endl;”這個。
再把“
return temp;
}
?}
”改成“
}
return temp;
?}
”
不然你函數里的循環就包括return temp了。就這些了
2020-01-19
等等,你這個代碼不止這一個問題
2020-01-19
你的代碼if(條件)的括號后面不能有這個“;”符號,去掉就行了