hoSSohbeT.com  Sohbet  forumlari

Anasayfa Bugünki Mesajlar Forumları Okundu Kabul Et
Geri git   hoSSohbeT.com Sohbet forumlari > Bilgisayar ve İnternet Dünyası > Bilgisayar - İnternet > Bilgisayar Dünyası > Programlama > C ve C++
Kayıt ol Yardım Sohbet Gazete oku Diyetsaglik Üye Listesi Ajanda Arama Bugünki Mesajlar Forumları Okundu Kabul Et



Cevapla
 
LinkBack Seçenekler Stil
Alt 04-09-08, 17:45   #1
Dokunma Yanarsın
 
aLayıNaiSyaN - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: 04-02-08
Nerden: . . .
Mesajlar: 1,981
Tecrübe Puanı: 496 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000
C++ Başkent Bulma Oyunu

C++ Başkent Bulma Oyunu
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);
}
__________________
aLL Hope iS Gone

aLayıNaiSyaN isimli Üye şimdilik offline konumundadır  
Digg this Post!Bookmark Post in Technorati
Alıntı ile Cevapla
Cevapla

  • Submit Thread to Digg Digg
  • Submit Thread to del.icio.us del.icio.us
  • Submit Thread to StumbleUpon StumbleUpon
  • Submit Thread to Google Google
  • Bookmarks

    Seçenekler
    Stil

    Yetkileriniz
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is Açık
    Smileler Açık
    [IMG] Kodları Açık
    HTML-KodlarıKapalı
    Trackbacks are Açık
    Pingbacks are Açık
    Refbacks are Açık



    Bütün Zaman Ayarları WEZ olarak düzenlenmiştir. Şu Anki Saat: 13:31 .


    Powered by vBulletin Version 3.8.7
    Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
    Search Engine Friendly URLs by vBSEO 3.5.0 RC2
    Sohbet ve Sohbet odalari sitesi

    Sohbet Chat Forum Oyunlar1