n的值始终处于递增状态, while循环中没有break,一直有输入的话,是一定会溢出的. 根据需求再改一下程序吧. 如果int 型(-2^31 ~ 2^31-1)不能满足你的计算需求,就改用unsigned int 和更大的unsigned long long 型.