标题:求解为什么score()函数进不去啊
取消只看楼主
樊先知樊先知
Rank: 1
等 级:新手上路
帖 子:4
专家分:3
注 册:2015-3-5
 问题点数:0 回复次数:2 
求解为什么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: 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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-442372-1-1.html




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

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