08.01 Шахматни фигури

Напишете програма, която позволява въвеждането на координатите на две фигури, и отпечатва дали първата ще вземе втората, ако първата е:

  • топ
  • офицер
  • кон
  • царица
Публикувано в 12а с етикети , . Постоянна връзка.

4 Responses to 08.01 Шахматни фигури

  1. TVD каза:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        char a1,a2;
        int b1,b2;
        cout<<"horizontala i vertikala na purvata figura , koqto e TOP ";
        cin>>a1>>b1;
        cout<<"horizontala i vertikala na vtorata ";
        cin>>a2>>b2;
        if ((a1==a2)||(b1==b2)) cout<<"MOJE"<<endl;
        else cout<<"NE MOJE"<<endl;
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    
  2. TVD каза:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        char a1,a2;
        int b1,b2;
        cout<<"horizontala i vertikala na pyrvata figura , koqto e KON ";
        cin>>a1>>b1;
        cout<<"horizontala i vertikala na vtorata ";
        cin>>a2>>b2;
        if (((abs(a1-b1)==2)&&(abs(a2-b2)==1))||((abs(a1-b1)==1)&&(abs(a2-b2)==2))) cout<<"MOJE"<<endl;
        else cout<<"NE MOJE"<<endl;
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    
  3. TVD каза:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        int a1,a2,b1,b2;
        cout<<"horizontala i vertikala na purvata figura , koqto e OFICER ";
        cin>>a1>>b1;
        cout<<"horizontala i vertikala na vtorata ";
        cin>>a2>>b2;
        if (abs(b2-b1)==abs(a2-a1)) cout<<"MOJE"<<endl;
        else cout <<"NE MOJE"<<endl;
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    
  4. Nadq каза:
       int r1,k1,r2,k2;
         //za top
         cout<<"vuvedete koordinati  na topa :"<<endl;
         cin>>r1>>k1;
         cout<<"vuvedete kordinatite na dr figura :"<<endl;
         cin>>r2>>k2;
         if ((r1==r2)||(k1==k2))  
         cout<<"shte q udari:";
         else cout<<"nqma da q ydari "<<endl;
         
        //za oficer 
         cout<<"vuvedete koordinati na oficera :"<<endl;
         cin>>r1>>k1;
         cout<<"vuvedete koordinati na dr figura :"<<endl;
         cin>>r2>>k2;
           if (abs(k2-k1)==abs(r2-r1))
           cout<<"shte q udari :"<<endl;
         else cout<<"nqma da q udari"<<endl;
         
          // za kon
           cout<<"vuvedete koordinati na konq :"<<endl;
           cin>>r1>>k1;
           cout<<"vuvedete koordinati na dr figura :"<<endl;
           cin>>r2>>k2;
            if (((abs(k1-k2)==2)&&(abs(r1-r2)==1)) ||
               ((abs(k1-k2)==1)&&(abs(r1-r2)==2)))
             cout<<"shte q udari :"<<endl;
              else cout<<"nqma da q udari "<<endl;
              
              //za caricata
            cout<<"vuvedete koordinati na caricata :"<<endl;
           cin>>r1>>k1;
           cout<<"vuvedete koordinati na dr figura :"<<endl;
           cin>>r2>>k2;
              if (((r1==r2)||(k1==k2)) ||
               (abs(k2-k1)==abs(r2-r1)))
             cout<<"shte q udari :"<<endl;
               else cout<<"nqma da q udari "<<endl;
            

Вашият коментар