简单分段函数求职

来源:互联网 发布:js中for in循环 编辑:程序博客网 时间:2024/06/04 19:06
01./* 02.*Copyright(C) 2014 ,烟台大学计算机与控制工程学院 03.*ALL rights reserved. 04.*文件名称:first.cpp 05.*作者:孙旭升 06.*完成日期:2014年10月30日 07.*版本号:v1.0 08.* 09.*问题描述:计算函数的值:当x>=1时,y=x-1,否则,y=-x+1 10.*输入描述:一个任意的整数x 11.*程序输出:对应的y值 12.*/  #include <iostream>using namespace std;int main(){    int x,y;    cout<<"输入一个整数:";    cin>>x;    if(x>=1)        y=x-1;    else        y=-x+1;    cout<<"函数的值:"<<y<<endl;    return 0;}


0 0