谁能帮忙debug,谢!
查看原帖
谁能帮忙debug,谢!
555590
伏地魔老杨楼主2022/6/20 20:44
#include <iostream>
using namespace std;
int a[6];
int main()
{
    int cnt = 0;
    for (int i = 0; i <= 4; i++) 
    {
        cin >> a[i];
        if (a[i] % 3 == 0)
        {
            if (i == 0) 
            {
                a[4] += a[i] / 3;
                a[1] += a[i] / 3;
            }
            else if (i == 4)
            {
                a[0] += a[i] / 3;
                a[3] += a[i] / 3;
            }
            else
            {
                a[i+1] += a[i] / 3;
                a[i-1] += a[i] / 3;
            }
            a[i] /= 3;
        }
        else
        {
            cnt += a[i] % 3;
            a[i] -= a[i] % 3;
            i--;
            continue;
        }
    }
    for (int i = 0; i <= 4; i++) cout << a[i] << " ";
    cout << endl;
    cout << cnt;
    return 0;
}
2022/6/20 20:44
加载中...