c

时间:2016-12-01 23:48:28

标签: c loops sentinel

我有以下代码,我希望它只在输入一次哨兵号码后中断,但此刻我必须输入两次哨兵号码才能打破代码。有什么想法吗?

#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;
}

2 个答案:

答案 0 :(得分:1)

更改为:

//div[text()='Admin']

答案 1 :(得分:0)

while (1)                           
{
    scanf_s("%d",&ID[i]);

    if (ID[i] == Sentinel_Numb)
        break; 

    scanf_s("%f", &seconds[i]);

    if (seconds[i] == Sentinel_Numb)
        break;
    i++;
}