C++ 如何判断计算式的计算过程中出现负数(●´∀`●)路
C++ 如何判断计算式的计算过程中出现负数(●´∀`●)路
C++ 如何判断计算式的计算过程中出现负数(●´∀`●)路
C++ 如何判断计算式的计算过程中出现负数(●´∀`●)路
#include<iostream>//万能头文件 #include<bits/stdc++.h>
using namespace std;
int positive(int n)
{
if(n>0){
cout<<"positive";
}
else if(n==0){
cout<<"zero";
}
else{
cout<<"negative";
}
}
int main()
{
int n;
cin>>n;
positive(n);
return 0;
}
你是想遍历一个算术表达式内是否存在负数吗?如果是话的匹配这个字符串内的-号就知道了