请问怎么用 getchar 读取输出复数?
#include int main() { int num= 0,nn=0; printf("Type data including a number and press \"Enter\"\n"); char ch = getchar(); while (ch '9' && ch!='-' ) { ch= getchar (); } while (ch >= '0' && ch <= '9' || ch=='-') { num = num * 10 + ch - '0'; if (ch=='-') { nn=num; num=0; }ch = getchar();" } printf("Number is %d,negative number is -%d \n", num,nn);} 用它读取负数时还是显示正数,复数显示-0,请问这是怎么回事?