# include "stdio.h" int main(void) { float x,sum=0; printf("请输入(输入非正数时结束):"); scanf("%f",&x); while(x>0) { sum+=x; scanf("%f",&x); } printf("sum=%.3f\n",sum); }