diff --git a/2207/万维C/1-答案.c b/2207/万维C/1-答案.c new file mode 100644 index 0000000..a492f3f --- /dev/null +++ b/2207/万维C/1-答案.c @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------- +³ÌÐòÉè¼Æ +------------------------------------------------------------------------ +ÔÚ²Í×ÀÉϳԷ¹£¬Ã¿ÈËÒ»Ö»·¹Í룬2ÈËÒ»Ö»²ËÍ룬3ÈËÒ»Ö»ÌÀÍ룬һ¹²ÓÃÁËn¸öÍ룬Çë±àдº¯ÊýËãÒ»Ë㣬һ¹²Óм¸È˳Է¹£¬¼ÆËã³öʹÓÃÁ˼¸¸ö·¹Í룬¼¸¸ö²ËÍ룬¼¸¸öÌÀÍë?Çë×¢Ò⣺¼ÆËã¹ý³ÌÖвËÍëºÍÌÀÍëµÄÊýÁ¿Òª±£Ö¤¹»ÓÃÇÒÊÇÕûÊý +ʾÀýÊäÈ룺 +¡¾ÇëÊäÈë×ÜÍëÊýn: ¡¿25 +Ò»¹²ÓÐ13È˳Է¹ +ʹÓÃÁË13¸ö·¹Íë +ʹÓÃÁË7¸ö²ËÍë +ʹÓÃÁË5¸öÌÀÍë +------------------------------------------------------------------------ +×¢Ò⣺²¿·ÖÔ´³ÌÐò¸ø³öÈçÏ¡£ÇëÎð¸Ä¶¯Ö÷º¯Êýmain»òÆäËüº¯ÊýÖиø³öµÄÄÚÈÝ£¬½öÔÚ + Program-EndÖ®¼äÌîÈëÈô¸ÉÓï¾ä¡£ + ²»ÒªÉ¾³ý±êÖ¾·ñÔò²»µÃ·Ö¡£ + ²»ÒªÐ޸Ļòɾ³ýProgram-EndÖ®ÍâµÄÄÚÈÝ·ñÔò²»µÃ·Ö¡£ +----------------------------------------------------------------------*/ + +#include +#include + +// º¯ÊýÉùÃ÷£¬ÓÃÓÚ¼ÆËã³Ô·¹µÄÈËÊýÒÔ¼°·¹Íë¡¢²ËÍëºÍÌÀÍëµÄÊýÁ¿ +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