/*----------------------------------------------------------------------
程序设计
------------------------------------------------------------------------
在餐桌上吃饭,每人一只饭碗,2人一只菜碗,3人一只汤碗,一共用了n个碗,请编写函数算一算,一共有几人吃饭,计算出使用了几个饭碗,几个菜碗,几个汤碗?请注意:计算过程中菜碗和汤碗的数量要保证够用且是整数
示例输入:
【请输入总碗数n: 】25
一共有13人吃饭
使用了13个饭碗
使用了7个菜碗
使用了5个汤碗
------------------------------------------------------------------------
注意:部分源程序给出如下。请勿改动主函数main或其它函数中给出的内容,仅在
      Program-End之间填入若干语句。
      不要删除标志否则不得分。
      不要修改或删除Program-End之外的内容否则不得分。
----------------------------------------------------------------------*/

#include <stdio.h>
#include <math.h>

// 函数声明,用于计算吃饭的人数以及饭碗、菜碗和汤碗的数量
int calculateDiningDetails(int n, int *riceBowls, int *vegetableBowls, int *soupBowls);

int main() {
    int n;
         int riceBowls, vegetableBowls, soupBowls,people;
    printf("【请输入总碗数n: 】");
    scanf("%d", &n);

   
    // 调用函数计算吃饭的人数以及饭碗、菜碗和汤碗的数量
     people = calculateDiningDetails(n, &riceBowls, &vegetableBowls, &soupBowls);

    // 输出结果
    if (people!= -1) {
        printf("一共有%d人吃饭\n使用了%d个饭碗\n使用了%d个菜碗\n使用了%d个汤碗\n", people, riceBowls, vegetableBowls, soupBowls);
    } else {
        printf("没有符合条件的组合。\n");
    }

    return 0;
}

// 函数定义,用于计算吃饭的人数以及饭碗、菜碗和汤碗的数量
int calculateDiningDetails(int n, int *riceBowls, int *vegetableBowls, int *soupBowls) {
        int x,totalBowls;


/**********Program**********/
	for(x=3;x<n;x++){//n为碗的总数 x为当前吃饭人数 
		*riceBowls = x;//饭碗数量等于人数 
		*vegetableBowls = x%2==0?x/2:x/2+1;//菜碗数量计算 每2人一个碗不足2人也要有碗 
		*soupBowls = x%3==0?x/3:x/3+1;//汤碗数量计算
		totalBowls = *riceBowls + *vegetableBowls + *soupBowls;
		if(totalBowls == n){
			return x;
		}
	}
	return -1;
/**********  End  **********/
  
}