第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

我輸入一個(gè)非零的數(shù),運(yùn)行結(jié)果是 1606416392,但是我的數(shù)組是{1,2,3,4}。當(dāng)我輸入0時(shí),運(yùn)行結(jié)果是 1。這是怎么回事????

#include<iostream>

#include<stdlib.h>

using namespace std;

namespace A

{

? ? int GetMaxOrMin(int *arr,int count,bool isMax)

{

? ? int temp=arr[0];

? ? if(isMax)

? ? {

? ? ? ? for(int i=1;i<=count; i++)

? ? ? ? {

? ? ? ? ? ? if(temp<arr[i])

? ? ? ? ? ? ? ? temp=arr[i];

? ? ? ? }

? ? }

? ? else

? ? {

? ? ? ? for(int i=1;i<=count; i++)

? ? ? ? {

? ? ? ? ? ? if(temp>arr[i])

? ? ? ? ? ? ? ? temp=arr[i];

? ? ? ? }

? ? }

? ? return temp;

}


}

int main(void)

{

? ? int arr1[4]={1,2,3,4};

? ? int count=4;

? ? bool ismax=false;

? ? cin>>ismax;

? ? cout<<A::GetMaxOrMin(arr1,count,ismax)<<endl;

?? ?

?? ?

?? ?

}


正在回答

1 回答

?for(int i=1;i<=count; i++)

? ? ? ? {

? ? ? ? ? ? if(temp<arr[i])

? ? ? ? ? ? ? ? temp=arr[i];

? ? ? ? }

for 循環(huán)里不要用<=count ,數(shù)組下標(biāo)會(huì)越界,寫<count就ok了.

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

YiShen23 提問者

明白了,謝謝
2017-05-01 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
C++遠(yuǎn)征之起航篇
  • 參與學(xué)習(xí)       290964    人
  • 解答問題       817    個(gè)

C++亮點(diǎn)盡在其中,本課程是在C語(yǔ)言基礎(chǔ)上的一個(gè)延伸,得以升華

進(jìn)入課程

我輸入一個(gè)非零的數(shù),運(yùn)行結(jié)果是 1606416392,但是我的數(shù)組是{1,2,3,4}。當(dāng)我輸入0時(shí),運(yùn)行結(jié)果是 1。這是怎么回事????

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)