| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1763 人关注过本帖
标题:求代码,C语言没学好,真心不会啊,大佬帮帮忙😭
只看楼主 加入收藏
丰田甜
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-4-18
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:7 
求代码,C语言没学好,真心不会啊,大佬帮帮忙😭
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 代码 C语言 真心 
2018-04-18 13:06
nosnoy
Rank: 9Rank: 9Rank: 9
来 自:mcu
等 级:贵宾
威 望:14
帖 子:541
专家分:1178
注 册:2016-9-17
收藏
得分:10 
所以你要啥子码 图裂了

前排提示百度啥都有

穷举是最暴力的美学
2018-04-18 13:45
nosnoy
Rank: 9Rank: 9Rank: 9
来 自:mcu
等 级:贵宾
威 望:14
帖 子:541
专家分:1178
注 册:2016-9-17
收藏
得分:0 
所以你要啥子码 图裂了

前排提示百度啥都有

穷举是最暴力的美学
2018-04-18 13:45
丰田甜
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-4-18
收藏
得分:0 

Three players, A, B, and C play a dice game, each player rolls two dice.

(The points of 2*3 = 6 dice should be set and stored in advance)

PART I:

Assume that each player can only see the points of his/her own two dice, simulate their game process.

Rules of PART I:

Starting from player A, the following steps are performed in turn.

First, the two dice thrown by the player A are output (indicating that A sees his/her dice), and then two numbers a and b are required to be input to represent A's guess for all dice, which means the number of b point dices in total is at least a.

Then it's the next player B's turn. After seeing his own dice, B can choose to enter 0 0 (two zeros) for "I don't believe" or to enter a new pair of numbers c and d, which means he/she guesses "there are at least c d points in all dice", where c,d must satisfy c≥a, and when c=a, d>b.

The game continues until someone input 0 0 (two zeros).

Optional rules:1 point dice can be regarded as any number of points.

For example:

O: A's turn: A has 2 and 1
I: 2 4
O: B's turn: B has 3 and 2
I: 2 3
O: Invalid input.
O: B's turn: B has 3 and 2
I: 3 2
O: C's turn: C has 2 and 5
I: 3 5
O: A's turn: A has 2 and 1
I: 4 2
O: B's turn: B has 3 and 2
I: 0 0

If someone (let's say player B above) enters 0 0 (two zeros), then show all 2 * 3 = 6 dice, determine the current player's "unbelieving" is right or wrong to judge the loser of the game: Assume that the previous player's input is x y. If the number of dice in y points is less than x (in a total of 6 dice), then the previous player (A) loses, otherwise, the current player (B) loses.

For example:

O: A's turn: A has 2 and 1
I: 2 4
O: B's turn: B has 3 and 2
I: 2 3
O: Invalid input.
O: B's turn: B has 3 and 2
I: 3 2
O: C's turn: C has 2 and 5
I: 3 5
O: A's turn: A has 2 and 1
I: 4 2
O: B's turn: B has 3 and 2
I: 0 0
O: All dices: 2 1 3 2 2 5
Loser is A. (Without optional rules)

Loser is B. (With optional rules)



PART II:

Play this game from the perspective of God, i.e. you can see all of the 6 dice.

Rules of PART II:

Observe all 6 dice and output the optimal combination of a and b, which means it  will certainly  be wrong for any other player to guess again.

For example:

O: All dices: 2 1 3 2 2 5
Best answer: 3 2 (Without optional rules)

Best answer: 4 2 (With optional rules)

注:

O: 用例输出,I: 用例输入,不必写在程序输出里

要求体现代码的良好风格、友好界面、算法和代码的高执行效率等。

其他可选部分:例如,可选择2-5之间的数字作为游戏人数及骰子个数等。

开放时间:    2018年04月02日 星期一 12:00
截止时间:    2018年04月21日 星期六 00:00
上传一个文件
跳过 导航
导航
我的主页
2018-04-18 14:44
李晨经纪人
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:6
帖 子:175
专家分:848
注 册:2018-2-14
收藏
得分:10 
看到都是英文,眼睛有点花
程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int checknum(int a,int b,int c,int d)
{
    if(a>6||b>6||c>6||d>6||a<0||b<0||c<0||d<0)
        return 1;
    if(c==0&&d==0)
        return 0;
    if(c>a||(c==a&&d>b))
        return 0;
    else
        return 1;
}
void catchlier(int a,int b,int *p,int o)
{
    int i,m=0,n=0;
    for(i=0;i<6;++i,*(p++))
    {
        if(*p==1)
            m++;
        if(*p==b)
            n++;
    }
    if(n>=a)
        printf("Loser is %c. (Without optional rules)\n",o);
    else
        printf("Loser is %c. (Without optional rules)\n",o>65?o-1:67);
    if(m+n>=a)
        printf("Loser is %c. (With optional rules)\n",o);
    else
        printf("Loser is %c. (With optional rules)\n",o>65?o-1:67);
}
int main(void)
{
    int points[6],i,n=65,j=0;
    int    a,b,c,d;
    srand((unsigned)time(NULL));
    for(i=0;i<6;++i)
        points[i]=rand()%6+1;
    printf("A's turn: A has %d and %d\n",points[0],points[1]);
    scanf("%d%d",&a,&b);
    while(1)
    {
        j++;
        n++;
        if(n>67)
            n=65;
        if(j>2)
            j=1;
        printf("%c's turn: %c has %d and %d\n",n,n,points[j*2],points[j*2+1]);
        scanf("%d%d",&c,&d);
        while(checknum(a,b,c,d))
        {
            printf("Invalid input.\n");
            printf("%c's turn: %c has %d and %d\n",n,n,points[j*2],points[j*2+1]);
            scanf("%d%d",&c,&d);
        }
        if(c==0&&d==0)
            break;
        a=c;
        b=d;
    }
    printf("All dices:");
    for(i=0;i<6;++i)
        printf("%d ",points[i]);
    putchar('\n');
    catchlier(a,b,points,n);
    return 0;
}
2018-04-18 21:45
丰田甜
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-4-18
收藏
得分:0 
谢谢大佬,各位同学,如果谁看到了,不要copy,我已经交了,咱两会一起扑街的~~~~
2018-04-20 20:55
nosnoy
Rank: 9Rank: 9Rank: 9
来 自:mcu
等 级:贵宾
威 望:14
帖 子:541
专家分:1178
注 册:2016-9-17
收藏
得分:0 
回复 6楼 丰田甜
所以就一起扑街咯

穷举是最暴力的美学
2018-04-20 21:01
丰田甜
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-4-18
收藏
得分:0 
回复 7楼 nosnoy
大哥,不带这样的
2018-04-20 21:11
快速回复:求代码,C语言没学好,真心不会啊,大佬帮帮忙&#128557;
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031923 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved