| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 515 人关注过本帖
标题:求解为什么score()函数进不去啊
只看楼主 加入收藏
樊先知樊先知
Rank: 1
等 级:新手上路
帖 子:4
专家分:3
注 册:2015-3-5
收藏
 问题点数:0 回复次数:4 
求解为什么score()函数进不去啊
#include<stdio.h>
#include<windows.h>      //问题是怎么调用score函数进行游戏
#include<iostream>
#include<stdlib.h>

int sec,t;
static int scores[3]={0};

int timeend(int);     //时间控制程序
void highest();        //最高分显示程序
void score(int);          //显示分数程序
void compair(int p);     //比较大小


int main()
{
    printf("choose how long you want to play(10 or 30 or 60) , input it\n");
    scanf("%d",&sec);
    t=sec;
    timeend(sec),score(sec);
    if(timeend(sec)==0)
        printf("input 5 to restart\n");
    return 0;
}

int timeend(int)   //时间控制程序
{
    int time;
    for(;sec>=0;sec--)
    {
        printf("you have %2d seconds",sec);
        Sleep(1000);
        system("cls");
    }
    return 0;
}

void score(int)     //显示分数程序
{
    char button;
    for(;sec>=0;)
    {
        scanf("%c",button);      //输入字符5则分数加一
        if (t==10)
            {
                while(button=='5')
                {
                    scores[0]++;
                    printf("%d",scores[0]);
                    compair(scores[0]);
                    break;
                    }
            }
            if (t==30)
                {
                    while(button=='5')
                    {
                        scores[1]++;
                        printf("%d",scores[1]);
                        compair(scores[1]);
                        break;
                    }
                }
                if (t==60)
                    {
                        while(button=='5')
                        {
                            scores[2]++;
                            printf("%d",scores[2]);
                            compair(scores[2]);
                            break;
                        }
                    }
                    button='0';
    }
}

void highest()
{
    int model;
    printf("what is the highest type ? input it\n");
    scanf("%d",&model);
    if (model==10)
        printf("10 seconds , the highest score is %2d",scores[0]);
    else if (model==30)
        printf("30 seconds , the highest score is %2d",scores[1]);
    else if (model==60)
        printf("60 seconds , the highest score is %2d",scores[2]);
}

void compair(int p)
{
    if (sec==10&&p>=scores[0])
        {
            scores[0]=p;
            exit (0);
        }
    else if (sec==30&&p>=scores[1])
        {
            scores[1]=p;
            exit (0);
        }
    else if (sec==60&&p>=scores[2])
        {
            scores[2]=p;
            exit (0);
        }
}
搜索更多相关主题的帖子: highest include scores 游戏 
2015-03-05 10:59
执笔画江山
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:3
帖 子:265
专家分:1010
注 册:2015-1-13
收藏
得分:0 
没仔细看 大体浏览了下
void score(int) 中
 scanf("%c",button);  你觉得scanf函数你用的对吗?
 scanf("%c",&button);

授人以鱼,不如授人以渔
2015-03-05 11:11
执笔画江山
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:3
帖 子:265
专家分:1010
注 册:2015-1-13
收藏
得分:0 
没仔细看 大体浏览了下
void score(int) 中
 scanf("%c",button);  你觉得scanf函数你用的对吗?
 scanf("%c",&button);

授人以鱼,不如授人以渔
2015-03-05 11:11
樊先知樊先知
Rank: 1
等 级:新手上路
帖 子:4
专家分:3
注 册:2015-3-5
收藏
得分:0 
回复 3楼 执笔画江山
谢了
2015-03-05 15:24
樊先知樊先知
Rank: 1
等 级:新手上路
帖 子:4
专家分:3
注 册:2015-3-5
收藏
得分:0 
回复 3楼 执笔画江山
凡有我微信号者,可凭此微信号,到附近各大超市领取特大汤圆十袋!…………………………………………………………………………………………………………………………………………………………
领取方式:拿起就跑,越快越好。领取后有机会获得:拘留所七日游,时尚囚衣,炫酷手铐脚链,包吃包住,还能按摩!还等什么,赶快行动吧。如果你笑了,我的心意就到了!祝大家元宵佳节快乐!!
2015-03-05 15:26
快速回复:求解为什么score()函数进不去啊
数据加载中...
 
   



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

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