Заменить в коде for на if

помогите заменить for в коде на If, switch.

    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    int main()
    {
        double res;
        int c, ax, ay, bx, by;
        int a[2];
        int b[2];
        float res_baza = INFINITY;
    
        const int i = 4;
        int xa[i]{};
        int ya[i]{};
    
        const int j = 4;
        int xb[j]{};
        int yb[j]{};
    
       for (int i = 0; i < 4; i++)
       {    
            cout << "xa" << i << "=";
            cin >> xa[i];
        }
        for (int i = 0; i < 4; i++)
        {
            cout << "ya" << i << "=";
            cin >> ya[i];
        }
        for (int j = 0; j < 4; j++)
        {
            cout << "xb" << j << "=";
            cin >> xb[j];
        }
        for (int j = 0; j < 4; j++)
        {
            cout << "yb" << j << "=";
            cin >> yb[j];
        }
    
        cout << "vse rasstiyaniya mezhdu ai & bi: " << endl;
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                res = sqrt(pow((xb[j] - xa[i]), 2) + pow((yb[j] - ya[i]), 2));
                cout << res << endl;
                if (res_baza > res)
                {
                    res_baza = res;
                    ax = xa[i];
                    ay = ya[i];
                    bx = xb[j];
                    by = yb[j];
                }
            }
        }
        cout << endl;
        cout << "a={" << ax << ", " << ay << "} " << "b={" << bx << ", " << by << "}" << endl;
        cout << "min rasstoyanie= " << res_baza << endl;
        return 0;
    }

Ответы (0 шт):