online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <conio.h> #include <Windows.h> #include <string> const HANDLE konsolOutputHandle = GetStdHandle(STD_OUTPUT_HANDLE); short genislik, yukseklik, mayinSayisi, left, top,kapaliAlanSayisi; byte** harita; void git(const short x, const short y) { SetConsoleCursorPosition(konsolOutputHandle, { x,y }); } void satiriTemizle(const short x, const short y) { git(0, y); std::cout << std::string(80, ' '); git(x, y); } void mesajYaz(const short x, const short y, const std::string mesaj) { satiriTemizle(x,y); std::cout << mesaj; } int integerSor(const std::string soru,const int minimum,const int maksimum) { int cevap; while (true) try { mesajYaz(2,23, soru); std::cin >> cevap; if (cevap<minimum || cevap>maksimum) { mesajYaz(2,23, "Lutfen " + std::to_string(minimum) + " ve " + std::to_string(maksimum) + " arasinda degerler girin."); _getch(); } else return cevap; } catch (...) { mesajYaz(2,23, "Lutfen bir sayi giriniz."); _getch(); } } void goster(const short x, const short y) { byte deger = harita[y][x]; if (deger == 255) return; if (!deger) harita[y][x] = 255; git(left + x * 2, top + y); std::cout << (deger > 8 ? "*" : (deger ? std::to_string(deger) : " ")); --kapaliAlanSayisi; if (!deger) { if (x) { if (y) goster(x - 1, y - 1); goster(x - 1, y); if (y < yukseklik - 1) goster(x - 1, y + 1); } if (y) goster(x, y - 1); if (y < yukseklik - 1) goster(x, y + 1); if (x<genislik-1) { if (y) goster(x + 1, y - 1); goster(x + 1, y); if (y < yukseklik - 1) goster(x + 1, y + 1); } } } int main() { CONSOLE_SCREEN_BUFFER_INFOEX info; info.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX); GetConsoleScreenBufferInfoEx(konsolOutputHandle, &info); info.dwSize.X = 80; info.dwSize.Y = 25; SetConsoleScreenBufferInfoEx(konsolOutputHandle, &info); genislik = integerSor("Genisligi girin: ", 10, 20); yukseklik = integerSor("Yuksekligi girin: ", 10, 20); kapaliAlanSayisi = genislik * yukseklik; mayinSayisi = integerSor("Mayin sayisini girin: ", kapaliAlanSayisi / 10, kapaliAlanSayisi / 2); kapaliAlanSayisi -= mayinSayisi; harita = new byte * [yukseklik]; for (int i = 0; i < yukseklik; ++i) { harita[i] = new byte[genislik]; for (int j = 0; j < genislik; ++j) harita[i][j] = 0; } for (int i = 0; i < mayinSayisi; ++i) { short x = rand() % genislik, y = rand() % yukseklik; if (!harita[y][x] == 9) { --i; continue; } harita[y][x] = 9; if (y) { if (x) harita[y - 1][x - 1]++; harita[y - 1][x]++; if (x < genislik - 1) harita[y - 1][x + 1]++; } if (x) harita[y][x - 1]++; if (x < genislik - 1) harita[y][x + 1]++; if (y < yukseklik - 1) { if (x) harita[y + 1][x - 1]++; harita[y + 1][x]++; if (x < genislik - 1) harita[y + 1][x + 1]++; } } left = 40 - genislik; top = (23 - yukseklik) / 2; git(left, top-1); for (int i = 0; i < genislik; i++) std::cout << (char)('a' + i) << ' '; for (int i = 0; i < yukseklik; i++) { git(left - 2, top + i); std::cout << i + 1; if (i < 9) std::cout << ' '; for (int j = 0; j < genislik; ++j) std::cout << "? "; } while (kapaliAlanSayisi) { while (true) try { mesajYaz(2,23, "Koordinati girin: "); short satir; char sutun; std::cin >> satir >> sutun; if (satir<1 || satir>yukseklik) { mesajYaz(2,23, "Satir no 1 ile" + std::to_string(yukseklik) + " arasinda olmalidir."); continue; } if (sutun < 'a' || sutun>'a' + genislik) { mesajYaz(2,23, "Sutun 'a' ile" + std::to_string((char)('a' + genislik)) + " arasinda olmalidir."); continue; } short y = satir - 1, x = sutun - 'a'; goster(x, y); if (harita[y][x] > 8 && harita[y][x]<255) { mesajYaz(2,23, "BOOOM! Patladin!"); _getch(); return 0; } } catch (...) { mesajYaz(2,23, "Koordinat satır no, ardından sutun harfi seklinde girilmelidir."); } } mesajYaz(2,23, "KAZANDIN!"); _getch(); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue