#include "stdio.h"
int main() {
int hour, min;
printf("Please insert the time in the 24 hour format (hh:mm): "); //ask user about the the time
scanf("%d:%d", &hour, &min); Store the time
printf("%d", hour);//Checking to see what time I get
if (hour == 1, 2, 3, 4, 5, 6, 7, 22, 23, 24){ //Check if the hour time matches
printf("The closest departure time is 8:00 am and arriving at 10:16 am");
return 0;
}
else if(hour = 8){//Check if the hour time matches
printf("The closest departure time is 9:00 am and arriving at 10:16 am");
return 0;
}
return 0;
}
當我輸入08:00時,它總是會說「最近的出發時間是上午8點到達上午10點16分」我希望它說:「最近的發車時間爲9:00和10:16抵達」我沒有得到想要的輸入C
「小時== 1,2,3,4,5,6,7,22,23,24」和「小時= 8」都不代表您認爲他們的意思。 – user2357112
我不明白你的意思?你能詳細說明你想說什麼嗎? –
'hour = 8'將值8賦給變量小時 – bruceg