解题思路:
用暴力解法即可
注意事项:
参考代码:
#include<stdio.h>
int main()
{
int a,b,c,d,e;
scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
//1.
a = a / 3;
b = b + a;
e = e + a;
//2.
b = b / 3;
a = a + b;
c = c + b;
//3.
c = c / 3;
b = b + c;
d = d + c;
//4.
d = d / 3;
c = c + d;
e = e + d;
//5.
e = e / 3;
d = d + e;
a = a + e;
printf("%5d%5d%5d%5d%5d",a,b,c,d,e);
return 0;
}
0.0分
0 人评分
#include<stdio.h> int main() { int a1,a2,a3,a4,a5;//5个小朋友 scanf("%d %d %d %d %d",&a1,&a2,&a3,&a4,&a5); //从第一个小朋友开始,a1的糖果分三份,其余两份分给他相邻的a2,a5小朋友 a1=a1/3,a2=a2+a1,a5=a5+a1; a2=a2/3,a1=a1+a2,a3=a3+a2;//下面式子同理如上 a3=a3/3,a2=a2+a3,a4=a4+a3; a4=a4/3,a3=a3+a4,a5=a5+a4; a5=a5/3,a4=a4+a5,a1=a1+a5; printf("%5d%5d%5d%5d%5d",a1,a2,a3,a4,a5);//按5位宽度输出 }
汽水瓶 (C语言代码)浏览:764 |
C语言程序设计教程(第三版)课后习题8.3 (Java代码)浏览:1402 |
计算质因子 (C++代码)浏览:1827 |
【蟠桃记】 (C语言代码)浏览:698 |
1642题解浏览:784 |
数组与指针的问题浏览:760 |
1035 题解浏览:875 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:630 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:826 |
A+B for Input-Output Practice (I) (C语言代码)浏览:599 |