設置計數變量 int count = 0 循環遍歷整個數字串 while(ch != '/0') 如果查到空格則count加1 if(str[i] == ' ') count++ 剩下的自己思考思考唄 不然沒意思了