日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

c語言26字母打字游戲代碼

 EYYLTV 2024-06-29

?#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#include <string.h>

// 生成隨機文字

char* generateRandomWord() {

    // 定義一些可能的文字

    char* words[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};

    int randomIndex = rand() % (sizeof(words) / sizeof(words[0]));

    return words[randomIndex];

}

// 檢查用戶輸入是否正確

int checkInput(char* userInput, char* targetWord) {

    return strcmp(userInput, targetWord) == 0;

}

int main() {

    srand(time(NULL));  // 初始化隨機數(shù)種子

    char* targetWord = generateRandomWord();

    int score = 0;

    int timeLeft = 60;  // 假設(shè)游戲時間為 60 秒

    printf("輸入以下文字:%s\n", targetWord);

    char userInput[20];

    while (timeLeft > 0) {

        printf("剩余時間:%d 秒\n", timeLeft);

        scanf("%s", userInput);

        if (checkInput(userInput, targetWord)) {

            score++;

            targetWord = generateRandomWord();

            printf("正確!新的文字:%s\n", targetWord);

        } else {

            printf("錯誤,請重新輸入\n");

        }

        timeLeft--;

    }

    printf("游戲結(jié)束,您的得分是:%d\n", score);

    return 0;

}

    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多