/*
*Copyright (c) 2014, 烟台大学计算机学院
*All rights reserved.
*文件名称:week7-project4.cpp
*作者:于凯
*完成日期:2014年 10 月 16日
*版本号:v1.0
*
*问题描述:计算函数的值
*输入描述:一个函数X
*程序输出:对应的y值
*/
#include <iostream>
using namespace std;
int main()
{
double x,y;
cout<<"请输入x";
cin>>x;
if(x>=1)
{
y=x-1;
cout<<"y="<< y;
}
else
{
y=-x+1;
cout<<"y="<<y;
}
return 0;
}
运行结果:
学习心得:第一次使用if语句,对有了更好地认识。