一、问题及代码:
#include<iostream>
using namespace std;
int main()
{
int x,y;
cin>>x;
if(x>=1)
y=x-1;
else
y=-x+1;
cout<<y<<endl;
return 0;
}
项目二
二、 运行结果:
三、心得体会:
第二次上机实验,项目二使用了if语句。
四、知识点总结:
if语句的嵌套的使用,怎么使用。
一、问题及代码:
#include<iostream>
using namespace std;
int main()
{
int x,y;
cin>>x;
if(x>=1)
y=x-1;
else
y=-x+1;
cout<<y<<endl;
return 0;
}
二、 运行结果:
三、心得体会:
第二次上机实验,项目二使用了if语句。
四、知识点总结:
if语句的嵌套的使用,怎么使用。