Bzplus 2022-12-14 00:18 采纳率: 50%
浏览 37

C++ 如何判断计算式的计算过程中出现负数

C++ 如何判断计算式的计算过程中出现负数(●´∀`●)路

C++ 如何判断计算式的计算过程中出现负数(●´∀`●)路

  • 写回答

1条回答 默认 最新

  • 瑶池酒剑仙 2022-12-15 14:09
    关注
    
    #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;    
    }
    

    你是想遍历一个算术表达式内是否存在负数吗?如果是话的匹配这个字符串内的-号就知道了

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 12月14日