Results 1 to 5 of 5
Thread: Source C++
Hybrid View
-
15th November 2009 14:24 #1Registered User
Join Date: May:2008
Location: varna
Posts: 82
Source C++
,
, ( - ).
.
, ( , ) ( ) . , ,
:
Code:#include <windows.h> #include <iostream> using namespace std; string point; int player; int win=0,lp=0; string playerXoO; string xy=" ",xy1=" ",xy2=" "; string x1y=" ",x1y1=" ",x1y2=" "; string x2y=" ",x2y1=" ",x2y2=" "; void table() { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 11); cout << "Now Play Player: " << player << " !" << endl; cout << "\n\n"; cout << " y " << " y1 " << " y2 " << endl; cout << " _________________" << endl << endl; cout << "x " << xy << " | " << xy1 << " | " << xy2 << " " << endl; cout << " -----|-----|-----" << endl; cout << "x1 " << x1y << " | " << x1y1 << " | " << x1y2 << " " << endl; cout << " -----|-----|-----" << endl; cout << "x2 " << x2y << " | " << x2y1 << " | " << x2y2 << " " << endl; cout << " _________________" << endl << endl; cout << endl; } int game(void) { if (player == 1) { playerXoO="x"; } else playerXoO="o"; while(! win==1) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10); lp++; if (player==2) { playerXoO="o"; } if (player==1) { playerXoO="x"; } cin >> point; system("cls"); if(point.size() > 4) { cout << "Only 2 Simbol's: xy,xy1,xy2,x1y,x1y1,x1y2,x2y,x2y1,x2y2: "; cin >> point; } if(point=="xy" && xy == " ") { xy=playerXoO; } else if(point=="xy1" && xy1 == " ") { xy1=playerXoO; } else if(point=="xy2" && xy2 == " ") { xy2=playerXoO; } else if(point=="x1y" && x1y == " ") { x1y=playerXoO; } else if(point=="x1y1" && x1y1 == " ") { x1y1=playerXoO; } else if(point=="x1y2" && x1y2 == " ") { x1y2=playerXoO; } else if(point=="x2y" && x2y == " ") { x2y=playerXoO; } else if(point=="x2y1" && x2y1 == " ") { x2y1=playerXoO; } else if(point=="x2y2" && x2y2 == " ") { x2y2=playerXoO; } else { cout << "That Not Possoble\n\n"; lp=lp-2; if (player == 1) { player = 2; } else if (player == 2) { player = 1; } } table(); if (xy==playerXoO && x1y1==playerXoO && x2y2==playerXoO || xy==playerXoO && x1y==playerXoO && x2y==playerXoO || xy==playerXoO && xy1==playerXoO && xy2==playerXoO || x1y==playerXoO && x1y1==playerXoO && x1y2==playerXoO || x2y==playerXoO && x2y1==playerXoO && x2y2==playerXoO || xy1==playerXoO && x1y1==playerXoO && x2y1==playerXoO || xy2==playerXoO && x1y2==playerXoO && x2y2==playerXoO || xy2==playerXoO && x1y1==playerXoO && x2y==playerXoO) { lp=0; cout << "Player " << player << " Win!!! :)\n\n" << endl; xy=" ",xy1=" ",xy2=" ",x1y=" ",x1y1=" ",x1y2=" ",x2y=" ",x2y1=" ",x2y2=" "; system("pause"); system("cls"); break; } if (lp >= 16) { lp =0; cout << "No Winner! :(\n\n" << endl; xy=" ",xy1=" ",xy2=" ",x1y=" ",x1y1=" ",x1y2=" ",x2y=" ",x2y1=" ",x2y2=" "; system("pause"); system("cls"); break; } if (player == 1) { player = 2; } else if (player == 2) { player = 1; } lp++; } } int main() { system("cls"); cout << "Tic-Tac-Toe By NoFeAr\n\n"; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10); cout << "Select Player:" << endl; cout << "1 for X\n" << "2 for O" << endl; cin >> player; if (player != 1 && player != 2) { main(); } system("cls"); table(); game(); if (point=="") { return 0; } return main(); }
-
15th November 2009 16:59 #2
system(''cls") . , , .
:Code:void cls(HANDLE hConsole){ COORD coordScreen = { 0, 0 }; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbil; DWORD dwConSize; if(!GetConsoleScreenBufferInfo(hConsole, &csbil)) return; dwConSize = csbil.dwSize.X * csbil.dwSize.Y; if(!FillConsoleOutputCharacter(hConsole, (TCHAR)' ', dwConSize, coordScreen, &cCharsWritten)) return; if(!GetConsoleScreenBufferInfo( hConsole, &csbil)) return; if(!FillConsoleOutputAttribute( hConsole, csbil.wAttributes, dwConSize, coordScreen, &cCharsWritten)) return; SetConsoleCursorPosition(hConsole, coordScreen); }
, GetStdHandle(STD_OUTPUT_HANDLE) .Code:cls(GetStdHandle(STD_OUTPUT_HANDLE))
EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|
-
15th November 2009 17:41 #3Registered User
Join Date: May:2008
Location: varna
Posts: 82
,

windows?
-
15th November 2009 20:46 #4Registered User
Join Date: Dec:2007
Location: Sofia
Posts: 366
rabut,
, , , ( refactor, ).
- -, 3x3. .
-
17th November 2009 05:07 #5Registered User
Join Date: Oct:2006
Location: Plovdiv
Posts: 305
+1 ( bombera pheoman)
- , "cls" - ++ batch , ?
.prepBut nI vrbLike adjHungarian! qWhat's artThe adjBig nProblem?




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in