一本通 例2.17 分糖果

每人的糖果数都用整型定义,分成三份,分别分给相邻的人;输出setw()<iomanip>。

#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main()
{
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
a=a/3;e=e+a;b=b+a;
b=b/3;a=a+b;c=c+b;
c=c/3;b=b+c;d=d+c;
d=d/3;c=c+d;e=e+d;
e=e/3;a=a+e;d=d+e;
cout<<setw(5)<<a<<setw(5)<<b<<setw(5)<<c<<setw(5)<<d<<setw(5)<<e<<endl;
return 0;
}

posted @ 2022-08-13 09:58  zjtofficial  阅读(19)  评论(0编辑  收藏  举报