Skip to content

Instantly share code, notes, and snippets.

@ahoulgrave
Created August 22, 2013 22:48
Show Gist options
  • Save ahoulgrave/6313756 to your computer and use it in GitHub Desktop.
Save ahoulgrave/6313756 to your computer and use it in GitHub Desktop.
Ajedrez
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int pos[2] = {1,1};
while (pos[0] != 8 || pos[1] != 8) {
if (pos[0] < 8 && pos[1] < 7) {
pos[0] = pos[0] + 1;
pos[1] = pos[1] + 2;
} else if (pos[0] < 7 && pos[1] < 8) {
pos[0] = pos[0] + 2;
pos[1] = pos[1] + 1;
} else if (pos[1] == 8) {
pos[0] = pos[0] + 1;
pos[1] = pos[1] - 2;
}
printf("X: %d, Y: %d \n", pos[0], pos[1]);
}
system("PAUSE");
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment