解题思路:
注意事项:
参考代码:
用到数学函数ceil求较大整值
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
int datas[7];
int main()
{
int thr[] = { 0,5,3,1 },k=0,a[100];//thr[]为2*2在3*3所在包装箱里数量分别为4,3,2,1时可以摆放的数量
while (true)
{
int total = 0;
for (int i = 1; i <= 6; i++)
cin >> datas[i];
if (datas[1] == 0&& datas[2] == 0 && datas[3] == 0 && datas[4] == 0 && datas[5] == 0 && datas[6] == 0)
break;
total += datas[6] + datas[5] + datas[4] + (int)ceil(datas[3] / 4.0);
int last2 = datas[4] * 5 + thr[datas[3] % 4];
if (datas[2] > last2)
total += (int)ceil((datas[2] - last2) / 9.0);
int last1 = 36 * (total - datas[6]) - datas[5] * 25 - datas[4] * 16 - datas[3] * 9 - datas[2] * 4;
if (datas[1] > last1)
total += (int)ceil((datas[1] - last1) / 36.0);
a[k] = total;
k++;
}
for (int j = 0; j < k; j++)
cout << a[j] << endl;
}
0.0分
0 人评分
字符串的输入输出处理 (C语言代码)浏览:2024 |
DNA (C++代码)浏览:651 |
C语言程序设计教程(第三版)课后习题8.9 (C++代码)浏览:858 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:715 |
C语言程序设计教程(第三版)课后习题9.2 (Java代码)浏览:638 |
简单的a+b (C语言代码)浏览:534 |
大神老白 (C语言代码)浏览:648 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:508 |
DNA (C语言代码)浏览:540 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:602 |