-1
我有下面的代碼,我希望它在進入哨兵號碼後只能打破一次,但此刻我必須輸入兩次哨兵號碼來破解代碼。有任何想法嗎?哨兵循環執行在c
#include <stdio.h>// Include a standard C Library
#define Sentinel_Numb -1
int main(){
int ID[360];
float seconds[360];
int i = 0;
printf("please enter the ID and how many seconds to calculate enter -1 when done\n");
while (1)
{
scanf_s("%d",&ID[i]);
scanf_s("%f",&seconds[i]);
if(ID[i] == Sentinel_Numb || seconds[i] == Sentinel_Numb){
break;
}
i++;
}
return 0;
}
我想'i'定義和初始化的地方? – yano
不編譯...「我」沒有定義。 – TonyB
抱歉只編輯了問題來初始化我 – drez