| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 458 人关注过本帖
标题:我这个程序是不是缺库函数。?
只看楼主 加入收藏
chenmx
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-3-13
结帖率:0
收藏
已结贴  问题点数:10 回复次数:3 
我这个程序是不是缺库函数。?
#include <stdio.h>
#include <stype.h>
#include <stdlib.h>
#include <time.h>
#define TRUE 1
#define FALSE 0
void main()
{
    char another_game = 'Y';
    int correct = FALSE;
    int counter = 0;
        sequence_length = 0;
        i = 0;
    long seed = 0;
    int number = 0;
    long now = 0;
    long time_taken = 0;
    printf("\nTo play Simple Simon,");
    printf("watch the screen for a sequence of digits.");
    printf("\nWatch carefully,as the digits are only disaplayed""for a second!");
    printf("\nThe computer will remove them, and then prompt you ");
    printf("to enter the same sequence.");
    printf("\nWhen you do,you must put spaces between the digits.\n");
    printf("\nGood Luck!\nPress Enter to play\n");
    scanf("%c", &another_game);
    do
    {
        correct = TRUE;
        counter = 0;
        sequence_length = 2;
        time_taken = clock();
        while(correct)
        {
            sequence_length += counter++%3 == 0;
            seed = time(NULL);
            now = clock();
            srand((int)seed);
            for(i = 1l i <= sequence_length;i++)
            printf("%d",rand() % 10);
            for(;clock() - now < CLOCKS_PER_SEC;);
            printf("\r");
            for(i = 1; i <= sequence_length;i++)
                printf("  ");
            if(counter == 1)
                printf("\nNow you enter the sequence  - don't forger"" the spaces\n);
                else
                printf("\r");
            srand((int)seed);
            for(i =1; i<=sequence_length; i++)
            {
                scanf("%d", &number);
                if(number != rand() % 10)
                {
                    correct = FALSE;
                    break;
                }
            }
            printf("%s\n", correct? "Correct!": "Wrong!");
        }
        printf("\n\n Your score is %d", --counter * 100/ time_taken);
        fflush(stdin);
        printf("\nDo you want to play again (y/n)?");
        scanf("%c", &another_game);
    }while(toupper(another_game) == 'Y');
}
搜索更多相关主题的帖子: 函数 
2010-06-15 12:04
chenmx
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-3-13
收藏
得分:0 
运行就有一个错误
而且
这里,有个FOR语句后面加;大部分的没加。
不懂,求解答。
第3行  库函数,好象不存在,怎么办
2010-06-15 12:06
myhnuhai
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:3
帖 子:425
专家分:1725
注 册:2010-3-17
收藏
得分:10 
#include <stdio.h>
#include <stype.h>
#include <stdlib.h>
#include <time.h>
#define TRUE 1
#define FALSE 0
void main()
{
    char another_game = 'Y';
    int correct = FALSE;
    int counter = 0;  //你的这种定义是错误的,这样只是定义了counter,而sequence_length和i没有声明,如果你想吧这两个也声明为int的话就把sequence_length和凑奈特让后面的分号改为逗号;
        sequence_length = 0;
        i = 0;
    long seed = 0;
    int number = 0;
    long now = 0;
    long time_taken = 0;
    printf("\nTo play Simple Simon,");
    printf("watch the screen for a sequence of digits.");
    printf("\nWatch carefully,as the digits are only disaplayed""for a second!");
    printf("\nThe computer will remove them, and then prompt you ");
    printf("to enter the same sequence.");
    printf("\nWhen you do,you must put spaces between the digits.\n");
    printf("\nGood Luck!\nPress Enter to play\n");
    scanf("%c", &another_game);
    do
    {
        correct = TRUE;
        counter = 0;
        sequence_length = 2;
        time_taken = clock();
        while(correct)
        {
            sequence_length += counter++%3 == 0;
            seed = time(NULL);
            now = clock();
            srand((int)seed);
            for(i = 1l i <= sequence_length;i++)
            printf("%d",rand() % 10);
            for(;clock() - now < CLOCKS_PER_SEC;);
            printf("\r");
            for(i = 1; i <= sequence_length;i++)
                printf("  ");
            if(counter == 1)
                printf("\nNow you enter the sequence  - don't forger"" the spaces\n);
                else
                printf("\r");
            srand((int)seed);
            for(i =1; i<=sequence_length; i++)
            {
                scanf("%d", &number);
                if(number != rand() % 10)
                {
                    correct = FALSE;
                    break;
                }
            }
            printf("%s\n", correct? "Correct!": "Wrong!");
        }
        printf("\n\n Your score is %d", --counter * 100/ time_taken);
        fflush(stdin);
        printf("\nDo you want to play again (y/n)?");
        scanf("%c", &another_game);
    }while(toupper(another_game) == 'Y');
}


#include <stdio.h>
//#include <stype.h>
#include <stdlib.h>
#include <time.h>
#define TRUE 1
#define FALSE 0
void main()
{
    char another_game = 'Y';
    int correct = FALSE;
    int counter = 0,
        sequence_length = 0,
        i = 0;
    long seed = 0;
    int number = 0;
    long now = 0;
    long time_taken = 0;
    printf("\nTo play Simple Simon,");
    printf("watch the screen for a sequence of digits.");
    printf("\nWatch carefully,as the digits are only disaplayed""for a second!");
    printf("\nThe computer will remove them, and then prompt you ");
    printf("to enter the same sequence.");
    printf("\nWhen you do,you must put spaces between the digits.\n");
    printf("\nGood Luck!\nPress Enter to play\n");
    scanf("%c", &another_game);
    do
    {
        correct = 1;
        counter = 0;
        sequence_length = 2;
        time_taken = clock();
        while(correct)
        {
            sequence_length += counter++%3 == 0;
            seed = time(NULL);
            now = clock();
            srand((int)seed);
            for(i = 1; i <= sequence_length;i++)
            printf("%d",rand() % 10);
            for(;clock() - now < CLOCKS_PER_SEC;);
            printf("\r");
            for(i = 1; i <= sequence_length;i++)
                printf("  ");
            if(counter == 1)
                printf("\nNow you enter the sequence  - don't forger"" the spaces\n");
            else
                printf("\r");
            srand((int)seed);
            for(i =1; i<=sequence_length; i++)
            {
                scanf("%d", &number);
                if(number != rand() % 10)
                {
                    correct = 0;
                    break;
                }
            }
            printf("%s\n", correct? "Correct!": "Wrong!");
        }
        printf("\n\n Your score is %d", --counter * 100/ time_taken);
        fflush(stdin);
        printf("\nDo you want to play again (y/n)?");
        scanf("%c", &another_game);
    }while(toupper(another_game) == 'Y');
}

不要让肮脏的记忆,迷失了原本纯洁的心灵!
2010-06-15 12:16
chenmx
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-3-13
收藏
得分:0 
谢谢
但是  我还有一个问题
那个FOR  怎么有时候后面要加; 但大部分时候 却又不要呢
2010-06-15 12:32
快速回复:我这个程序是不是缺库函数。?
数据加载中...
 
   



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

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