ForumAlem
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Yetkinforum | ©phpBB | Bedava yardımlaşma forumu | Suistimalı göstermek | Cookies | Son tartışmalar
ForumAlem

ForumAlem
 
AnasayfaAnasayfa  Latest imagesLatest images  AramaArama  Kayıt OlKayıt Ol  Giriş yapGiriş yap  

 

 Başkent Bulma Oyunu C++

Aşağa gitmek 
YazarMesaj
KaoS
Admin
Admin
KaoS


Mesaj Sayısı : 170
Kayıt tarihi : 02/08/08
Yaş : 35
Nerden : KONYA

Başkent Bulma Oyunu C++ Empty
MesajKonu: Başkent Bulma Oyunu C++   Başkent Bulma Oyunu C++ Icon_minitimePerş. Ağus. 14, 2008 10:17 pm

Kod:
#include <String.h>
#include <Stdlib.h>
#include <Stdio.h>
#include <Time.h>

char State[50][255] = {"Alabama",
"Alaska",
"Arizona",
"Arkansas",
"California",
"Colorado",
"Connecticut",
"Delaware",
"Florida",
"Georgia",
"Hawaii",
"Idaho",
"Illinois",
"Indiana",
"Iowa",
"Kansas",
"Kentucky",
"Louisiana",
"Maine",
"Maryland",
"Massachusetts",
"Michigan",
"Minnesota",
"Mississippi",
"Missouri",
"Montana",
"Nebraska",
"Nevada",
"New Hampshire",
"New Jersey",
"New Mexico",
"New York",
"North Carolina",
"North Dakota",
"Ohio",
"Oklahoma",
"Oregon",
"Pennsylvania",
"Rhode Island",
"South Carolina",
"South Dakota",
"Tennessee",
"Texas",
"Utah",
"Vermont",
"Virginia",
"Washington",
"West Virginia",
"Wisconsin",
"Wyoming"};

char Capital[50][255] = {"Montgomery",
"Juneau",
"Phoenix",
"Little Rock",
"Sacramento",
"Denver",
"Hartford",
"Dover",
"Tallahassee",
"Atlanta",
"Honolulu",
"Boise",
"Springfield",
"Indianapolis",
"Des Moines",
"Topeka",
"Frankfort",
"Baton Rouge",
"Augusta",
"Annapolis",
"Boston",
"Lansing",
"St. Paul",
"Jackson",
"Jefferson City",
"Helena",
"Lincoln",
"Carson City",
"Concord",
"Trenton",
"Santa Fe",
"Albany",
"Raleigh",
"Bismarck",
"Columbus",
"Oklahoma City",
"Salem",
"Harrisburg",
"Providence",
"Columbia",
"Pierre",
"Nashville",
"Austin",
"Salt Lake City",
"Montpelier",
"Richmond",
"Olympia",
"Charleston",
"Madison",
"Cheyenne"};

int main()
{
srand(time(0));

int NumCorrect = 0;
int NumIncorrect = 0;

while(true)
{
int RandNum = rand() % 49;

if(!strlen(State[RandNum]))
{
while(!strlen(State[RandNum]))
{
RandNum = rand() % 49;
}
}

char Answer[255];
char Buffer[255];

sprintf(Buffer, "What is the capital of %s?", State[RandNum]);
puts(Buffer);
gets(Answer);

if(!strcmp(Answer, Capital[RandNum]))
{
NumCorrect ++;

if(NumCorrect == 50)
{
puts("You guessed all 50 state capitals!\n"
"You win!!! (-:");

system("pause");

exit(EXIT_SUCCESS);
}

strcpy(State[RandNum], "");
strcpy(Capital[RandNum], "");
printf("%s, was correct! Excellent Job!\n", Answer);
}
else
{
NumIncorrect ++;

if(NumIncorrect == 3)
{
puts("You got three (3) answers incorrect.\n"
"You lose!!! )-:");

system("pause");

exit(EXIT_SUCCESS);
}

printf("%s, was incorrect. The correct answer was %s.\n", Answer, Capital[RandNum]);
}

printf("Your score is:\n"
"Correct : %i\n"
"Incorrect : %i\n\n", NumCorrect, NumIncorrect);

system("pause");
system("cls");
}

system("pause");

return(0);
Sayfa başına dön Aşağa gitmek
https://forumalem.hareketforum.net
 
Başkent Bulma Oyunu C++
Sayfa başına dön 
1 sayfadaki 1 sayfası
 Similar topics
-
» NET MAASI BULMA
» HARF NOTUNU BULMA
» pusu oyunu

Bu forumun müsaadesi var:Bu forumdaki mesajlara cevap veremezsiniz
ForumAlem :: Programlama Dilleri :: C / C++ / C#-
Buraya geçin: