(1)
#include<iostream.h>
void main()
{
int x,y;
cout<<"输入一个整数:";
cin>>x;
if (x<0)
y=-x;
else
y=x;
cout<<"|"<<x<<"|"<<"="<<y<<endl;
}
(2)
#include<iostream.h>
void main()
{
int x;
cout<<"输入一个整数:";
cin>>x;
if (x<0)
x=-x;
cout<<"|"<<x<<"|"<<"="<<x<<endl;
}
此博客展示了如何通过C++编程语言实现输入整数后判断其正负,并输出相应的绝对值。
94

被折叠的 条评论
为什么被折叠?



