Geri Sayım TV şovu ile ilgili basit bir program oluşturmaya çalışıyorum. Sadece başladım, bu yüzden benim problemim baştan. Kullanıcıdan bir sessiz harf veya sesli harf için c veya v girmesini istediğimde, sadece evet, hayır mı, yoksa tekrar deneyin mi diye kontrol ediyorum. Bu çalışır, ancak doğrudan tekrar eder, lütfen tekrar deneyin. Basit bir konu gibi hissediyorum ama ne olduğunu bilmiyorum.C Programlama: Basit Geri Sayım Programı
#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;
}
sizin girişinde yeni satır karakteri hesaba değildir ve buna da alt yordam aracılığıyla gönderilen oluyor bana görünüyor
Kod girintinizi düzeltin. –
C, Python değil, tuplleri geri dönemezsiniz. ('say, 'harf' sadece 'harfi' döndürür.) –
Bize göz ardı etmemizi söyleyecek bir şey eklemeyin. Eğer alakasızsa, sorunuzu kesin. – skrrgwasme