sdut-1117 C语言实验——求绝对值(选择结构)

点击打开链接

Problem Description

从键盘上输入任意一个整数,然后输出它的绝对值!

Input

从键盘上输入任意一个整数。

Output

输出它的绝对值。

Example Input

-4

Example Output

4
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n<0)
		cout<<n-2*n<<endl;
	else
		cout<<n<<endl;
	return 0;
}

/***************************************************
User name: YT1658506207邵雪源
Result: Accepted
Take time: 0ms
Take Memory: 228KB
Submit time: 2017-07-26 14:34:54
****************************************************/

posted @ 2017-08-13 15:43  衣带渐宽、为伊憔悴  阅读(354)  评论(0编辑  收藏  举报