Определить, может ли шахматный конь за один ход попасть из клетки с координатами (х1,у1) в клетку с координатами (х2,у2). (на Pascal)
Ответы
Ответ дал:
0
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
using namespace std;
int main ()
{
short int x1,y1,x2,y2;
cout << "Input x1: ";
cin>> x1;
cout<<endl<<"Input y1: ";
cin>> y1;
cout << "Input x2: ";
cin>> x2;
cout<<endl<<"Input y2: ";
cin>> y2;
if ((abs(x2-x1)!=1) || (abs(y2-y1) !=2))
{cout<<"NOT";} else
{cout<<"OK"<<endl;}
system("PAUSE");
return 0;
Вас заинтересует
2 года назад
2 года назад
3 года назад
3 года назад
10 лет назад