解题思路:
注意事项:
参考代码:
用到数学函数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 人评分
Pascal三角 (C语言代码)浏览:1188 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:337 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:840 |
IP判断 (C语言代码)浏览:763 |
关于C语言变量位置的问题浏览:272 |
时间转换 (C语言代码)浏览:627 |
多输入输出练习2 (C语言代码)浏览:1656 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:459 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:1001 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:1189 |