私はカウントダウンテレビ番組に関連する簡単なプログラムを作成しようとしています。私はそれを始めただけで、私の問題は最初からあります。ユーザーに子音または母音の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;
}
コードのインデントを修正しました。 –
CはPythonではなく、タプルを返すことはできません。 ( 'count、letter'は' letter'だけを返します。) –
無視するように言っているものは含めないでください。それが無関係な場合は、あなたの質問から切り離してください。 – skrrgwasme