问题及代码:
/*
*Copyringht (c) 2014,烟台大学计算机学院
*All right reserved.
*文件名称: test.cpp
*作 者:马明城
*完成日期:2014年10月17日
*版本号: v1.0
*问题描述:输入X的值,输出y的值
*输入描述:一个整数,代表x
*程序输出:一个整数,代表y
*/
#include <iostream>
using namespace std;
int main()
{
int x,y;
cout << "输入x的值:" ;
cin>>x;
if(x>=1)
y=x-1;
else
y=1-x;
cout<<"输出y的值:"<<y<<endl;
return 0;
}
运行结果: