解题思路:
注意事项:
参考代码:
#include <iostream>
using namespace std;
#include <iomanip>
int main()
{
int child_candies[5];
int i;
for (i = 0;i < 5;i++)
{
cin >> child_candies[i];
}
i = 0;
while (i < 5)
{
int pingjun = child_candies[i] / 3;
child_candies[i] = pingjun;
if (i == 0)
{
child_candies[5 - i - 1] += pingjun;
child_candies[i + 1] += pingjun;
}
else if (i == 4)
{
child_candies[5 - i - 1] += pingjun;
child_candies[i - 1] += pingjun;
}
else
{
child_candies[i - 1] += pingjun;
child_candies[i + 1] += pingjun;
}
i++;
}
for (int i = 0;i < 5;i++)
cout << setw(5) << child_candies[i];
return 0;
}
0.0分
0 人评分