#9635: 如何處理數字和非數字??求解


west7418 (shang)


題目:寫一程式計算一組數字的乘積。你的程式必須在讀入0時停止,若讀入非數字的
資料時,則跳過不予計算。
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int n,m;

while(1){
printf("輸入兩個數字:");
scanf("%d %d",&n,&m); 

if((n>='a')&&(n<='z'))
continue;
if((n>='A')&&(n<='Z')) 
continue;
if((n==0)||(m==0))
break; 
printf("%d*%d=%d\n",n,m,n*m); 


system("PAUSE");
return 0;
}
顯示數字和0都沒問題
只有輸入非數字,例如:a或b之類的,接下來就會一直跑
請問如何解決這個問題