加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 为什么我收到错误:’std’中的’操作符不匹配’?

发布时间:2020-12-16 10:40:52 所属栏目:百科 来源:网络整理
导读:我似乎无法理解为什么我收到以下代码的错误.我试过重写代码,似乎没有纠正问题.它不应该给我一个我能看到的错误. #include iostreamusing namespace std;int main(){ int month[12] = {0,31,60,91,121,152,182,213,243,274,305,335}; int year,dayNumber,day;
我似乎无法理解为什么我收到以下代码的错误.我试过重写代码,似乎没有纠正问题.它不应该给我一个我能看到的错误.

#include <iostream>
using namespace std;
int main()

{
    int month[12] = {0,31,60,91,121,152,182,213,243,274,305,335};
    int  year,dayNumber,day;

    cout<< "Please enter the month,by numerical value:";
    cin >> month;
    cout<<"Please enter the day,by numerical value:";
    cin >> day;
    cout<<"Please enter the year,by numerical value:";
    cin >> year;

解决方法

month是一个数组,所以它不支持像cin>>这样的语法.月;

根据逻辑,我认为你需要一个不同的月份数变量,从1到12.

int month_start_days[12] = {0,335};
int  year,day,month;

cout<< "Please enter the month,by numerical value:";
cin >> month;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读