double 是双精度的浮点型数据,输出使用 %lf格式声明. 另外如果为了减少程序执行多分支流程,建议 swich case 进行分支处理,这样可以只走一个分支,而不是你现在的走三个if 分支. switch ( ) { case this-value: Code to execute if == this-value break; case that-value: Code to execute if == that-value break; ... default: Code to execute if does not equal the value following any of the cases break; }