Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 程序第一次请求输入三次,然后在不应该请求输入时请求输入两次';t和结束过早_C++ - Fatal编程技术网

C++ 程序第一次请求输入三次,然后在不应该请求输入时请求输入两次';t和结束过早

C++ 程序第一次请求输入三次,然后在不应该请求输入时请求输入两次';t和结束过早,c++,C++,我的代码似乎第一次问了三次我的号码,然后在不应该问的时候问了两次,并且过早地结束了。我似乎不明白为什么 小背景:8月、6月、7月有30天(忽略7月31日)的天气。6月使用“0”,7月使用“1”,8月使用“2”S代表晴天,R代表雨天,C代表阴天。存储在二维数组中,并以格式显示给用户 这就是正在发生的事情 然后是更大的图景 它两次通过列表到达#30,然后完全按照我在末尾所说的做 我相信这段代码正在影响它 // char 'R' = 82 // char 'C' = 67 // char 'S'

我的代码似乎第一次问了三次我的号码,然后在不应该问的时候问了两次,并且过早地结束了。我似乎不明白为什么

小背景:8月、6月、7月有30天(忽略7月31日)的天气。6月使用“0”,7月使用“1”,8月使用“2”S代表晴天,R代表雨天,C代表阴天。存储在二维数组中,并以格式显示给用户

这就是正在发生的事情

然后是更大的图景

它两次通过列表到达#30,然后完全按照我在末尾所说的做

我相信这段代码正在影响它

// char 'R' = 82
// char 'C' = 67
// char 'S' = 83
bool flag = true;
char temp;
int calendar[3][30];
for( int x = 0; x <= 2; x++)
{
    for( int y = 0; y <= 29; y++)
    {
        if(x==0)
        {
            if(flag)
            {
                cout << "\nPlease enter weather for June";
                flag = false;
            }
            cout << "\nDay #" << y + 1 << " ";
            cin >> temp;
            temp = toupper(temp);
            calendar[x][y] = temp;
            if(y == 29)
                flag = true;
        }
        if(x=1)
        {
            if(flag)
            {
                cout << "\nPlease enter the weather for July, ignoring the 31st";
                flag = false;
            }
            cout << "\nDay #" << y + 1 << " ";
            cin >> temp;
            temp = toupper(temp);
            calendar[x][y] = temp;
            if(y == 29)
                flag = true;
        }
        if(x=2)
        {
            if(flag)
            {
                cout << "\nPlease enter the weather for August";
                flag = false;
            }
            cout << "\nDay #" << y + 1 << " ";
            cin >> temp;
            temp = toupper(temp);
            calendar[x][y] = temp;
            if(y == 29)
                flag = true;
        }

    }
}
flag = false;
for( int n = 0; n <= 2; n++)
{
    for( int m = 0; m <= 29; m++)
    {
        if(n == 0)
        {
            if(flag)
            {
                cout << "\nIn June the days of weather are as follows ";
                flag = false;
            }
            cout << "\n Day #" << m << ": ";
            if(calendar[n][m] == 82)
            {
                cout << "Rainy";
            }
            if(calendar[n][m] == 83)
            {
                cout << "Sunny";
            }
            if(calendar[n][m] == 67)
            {
                cout << "Cloudy";
            }
            if(m == 29)
            {
                flag = true;
            }

        }
        if(n == 1)
        {
            if(flag)
            {
                cout << "\nIn July the days of weather are as follows ";
                flag = false;
            }
            cout << "\n Day #" << m << ": ";
            if(calendar[n][m] == 82)
            {
                cout << "Rainy";
            }
            if(calendar[n][m] == 83)
            {
                cout << "Sunny";
            }
            if(calendar[n][m] == 67)
            {
                cout << "Cloudy";
            }
            if(m == 29)
            {
                flag = true;
            }

        }
        if(n == 2)
        {
            if(flag)
            {
                cout << "\nIn August the days of weather are as follows ";
                flag = false;
            }
            cout << "\n Day #" << m << ": ";
            if(calendar[n][m] == 82)
            {
                cout << "Rainy";
            }
            if(calendar[n][m] == 83)
            {
                cout << "Sunny";
            }
            if(calendar[n][m] == 67)
            {
                cout << "Cloudy";
            }
            if(m == 29)
            {
                flag = true;
            }
        }
    }
}
//字符'R'=82
//字符'C'=67
//char'S'=83
布尔标志=真;
焦炭温度;
国际日历[3][30];

对于(int x=0;x那么,如果不仔细阅读所有代码,我会立即看到两个错误:

if(x=1)
if(x=2)

它们应该是
if(x==1)
if(x==2)