/*
*Copyright(C)2013,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:李东奇
*完成日期:2013年10月15日
*版本号:v1.0
*
*输入描述:8 -7 1 0 -3
*问题描述:计算函数的值
*程序输出:7 6 0 1 2
*/
#include <iostream>
using namespace std;
int main()
{
int x,y;
cout<<"请输入一个整数:";
cin>>x;
if(x>=1)
{
y=x-1;
cout<<"函数值为:"<<y<<endl;
}
else
{
if(x<1)
{
y=-x+1;
cout<<"函数值为:"<<y<<endl;
}
}
return 0;
}
第八周项目1—求简分段函数的值
最新推荐文章于 2021-03-25 07:55:33 发布