首页 > 解决方案 > 为什么我的代码没有被读取为 0 是有效响应?

问题描述

我在让用户按 0 输出字符串或输出小时数值的代码区域遇到问题。它只会执行后一个选项,我不知道为什么。


//Do you want the minutes converted into hours?                
if ((a != 0) && (a != 1)) {
  cout << "That is not a valid answer. Please try again.";
}
  else if (a = 0) {                           <----- My issue with the code is here.
      cout << "Thank you for using the program";
  }
      else if (a = 1) {                       <----- My issue with the code
        average_hours_per_day = average_minutes_per_day/hour;
        cout << average_hours_per_day;
      }                                                       

标签: c++

解决方案


推荐阅读