有一分段函数如下:X>0时,Y=X^2+2X+1,X=0是,Y=-7,X<0时,Y=3X-5:写一段程序,输入X,输出Y

[复制链接]
查看11 | 回复1 | 2009-2-22 12:55:42 | 显示全部楼层 |阅读模式
#include #include float fun(int p){ float q; if(p>0) q=p*p+2*p+1; else if(p==0) q=-7; else q=3*p-5; return q; } int main(){ float x,y; cout>x; cout0 then y:=x*x+2*x+1;if x=0 then y:=-7;if x<0 then y:=3*x-5;...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行