2016-04-13 16 views
0

私はカウントダウンテレビ番組に関連する簡単なプログラムを作成しようとしています。私はそれを始めただけで、私の問題は最初からあります。ユーザーに子音または母音のcまたはvを入力するように依頼すると、はい、いいえを返すかどうかを確認しているか、もう一度お試しください。これは動作しますが、それが直接繰り返されますので、もう一度やり直してください。私はそれが簡単な問題のように感じるが、私はそれが何であるか分からない。Cプログラミング:単純なカウントダウンプログラム

#include "stdafx.h" 
#include <stdio.h> 
#include <string.h> 
#include <stdlib.h> 

int test(int count, char lett); 

int main() 
{ 
    int i, counter; 
    char letter; 
    //char *fileName = "webster.txt"; 

    printf("Welcome to Countdown!\n\n"); 
    printf("The objective of the game is to produce the largest word from the nine letter(consonants and/or vowels) that are chosen at random by you. "); 
    printf("The computer will then find the longest word available from these letters to compare with your word.\n"); 
    printf("Let's begin!\n"); 

    counter = 0; 

    while (counter < 9) { 
     printf("\nWould you like a consonant or a vowel(Enter either c or v)? "); 
     scanf_s("%c", &letter); 

     test(counter, letter); 

    } 

    return 0; 
} 

int test(int count, char letter) 
{ 
    if (letter == 'c') { 
    printf("yes\n"); 
    count++; 
    } 
    else if (letter == 'v') { 
     printf("no\n"); 
     count++; 
    } 
    else { 
     printf("Please try again\n"); 
    } 

    return count, letter; 
} 
+0

コードのインデントを修正しました。 –

+3

CはPythonではなく、タプルを返すことはできません。 ( 'count、letter'は' letter'だけを返します。) –

+1

無視するように言っているものは含めないでください。それが無関係な場合は、あなたの質問から切り離してください。 – skrrgwasme

答えて

1

あなたの入力に改行文字が含まれていないように思えますし、サブルーチンも同様に送信されています。 else if節を追加して\nをテストし、それに応じて対処してください。

あなたの上記のCには他にも複数の問題がありますが、それは私が知る限り、質問に関連するものです。

0

NUIGProbzあなたは基本的に9つの文字の配列を作成する必要が

、NULLに初期化し、 文字をプリントアウト、9文字の配列がいっぱいになるまで、ユーザは自分の手紙を選ぶ必要があり、VとCのARRを作成ユーザに単語を入力させ、辞書を照合させ、単語が存在する場合にはそのスコアをプリントアウトする。

関連する問題