#include<iostream>
using namespace std;
int main()
{
float x, y;
cin >> x;
if(x > 0)
{
y = 1;
}
else if (x == 0)
{
y = 0;
}
else
{
y = -1;
}
cout << y << endl;
return 0;
}
20.多分支结构
于 2022-12-16 11:32:03 首次发布
#include<iostream>
using namespace std;
int main()
{
float x, y;
cin >> x;
if(x > 0)
{
y = 1;
}
else if (x == 0)
{
y = 0;
}
else
{
y = -1;
}
cout << y << endl;
return 0;
}