Created
February 28, 2019 10:00
-
-
Save meftunca/561229019c4a31b836099d4b1e1ca78d to your computer and use it in GitHub Desktop.
C ile matriste en kısal yolu bulan program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void kisayol(int, int); | |
int labirent[8][6] = { | |
{1, 0, 0, 0, 0, 0}, | |
{1, 1, 0, 0, 0, 0}, | |
{0, 1, 0, 0, 0, 0}, | |
{0, 1, 1, 0, 0, 0}, | |
{0, 0, 1, 1, 1, 0}, | |
{1, 0, 0, 0, 1, 0}, | |
{0, 0, 0, 0, 1, 0}, | |
{0, 0, 0, 0, 1, 1}, | |
}; | |
int yol[8][6] = {0}; // gidilen yoldan bir daha gitmemeyi sağlar. | |
int main() | |
{ | |
kisayol(0, 0); | |
return 0; | |
} | |
void kisayol(int X, int Y) | |
{ | |
int y = 0; | |
int x = 0; | |
yol[x][y] = 1; // İçerisinde olunan koordinatı 1 yapar. Eğer [0][0] noktası 0 ise. | |
printf("koordinatlar %d , %d\n", x, y); | |
while (y < 8) | |
{ | |
while (x < 6) | |
{ | |
if (labirent[y][x] == 1) // 1 durumu varsa sağa doğru bak | |
{ | |
printf("koordinatlar x=> %d ,y=> %d\n", x, y); // koordinatı ver | |
if (labirent[y + 1][x] == 1) | |
{ | |
y++; | |
} | |
else | |
{ | |
x++; | |
} | |
} | |
// x++; | |
} | |
// y++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment