我有一個問題,解決這個問題: 我必須接收數字作爲輸入和第一個數字必須爲0(如果數字爲0關閉循環)但是編譯器讓我把一個號碼作爲輸入,當我按下ENTER它stucks 這裏是我的代碼:我的程序卡在do ,, while循環在c
#include <stdio.h>
int main(){
int num=0, max=0, first=0, a=0, b=0;
do{
b = num /10;
if(b==0)
scanf("%d", &num);
else{
a = num%10;
if (max < a){
max = a;
first = num;
a=b;
}
}
}
while(num > 0);
printf("%d\n%d", max, first);
}
我認爲你該[學會如何調試你的程序]了(https://ericlippert.com/2014/03/05/how-to-debug-small -程式/)。 –
我看錯了!發佈太快,然後太快刪除!它現在回來了! – TinyTheBrontosaurus