#include <stdio.h>
int main(){
int a[5];
int b,c;
int eat = 0;
int i = 0,j,k;
for(k=0; k<5; k++)
scanf("%d",a+k);
if(i == 0){
b = a[i]/3;
c = a[i]%3;
a[i] = b;
a[i+1] = a[i+1] + b;
a[4] = a[4] + b;
eat = eat + c;
i++;
}
for(i = 1; i < 4; i++){
b = a[i]/3;
c = a[i]%3;
a[i] = b;
a[i+1] = a[i+1] + b;
a[i-1] = a[i-1] + b;
eat = eat + c;
}
if(i == 4){
b = a[i]/3;
c = a[i]%3;
a[i] = b;
a[0] = a[0] + b;
a[i-1] = a[i-1] + b;
eat = eat + c;
}
printf("一轮游戏结束后,每个小朋友手上的糖果数量分别是:\n");
for(j = 0; j < 5; j++){
printf("%d ",a[j]);
}
printf("\n5个小朋友一共吃了 %d 颗糖果\n",eat);
return 0;
}
不知道为什么全错了,求路过的大神帮帮!