双分支if 问题转化为求y=|-x|输入一个数x若大于或等于0 直接输出原值若小于0 则为y取(-x)的值最后输出 x和y的值 #include<iostream.h>void main(){ float x,y; cout<<"请输入x:"; cin>>x; if(x>=0) { y=x; cout<<"y="<<y<<endl; } else { y=-x; cout<<"y=|"<<x<<"|="<<y<<endl; }}