Friday, October 7, 2022

Homework

 #include <iostream>

using namespace std;

int main()

{

    int k1, k2;

    int a[5][2] = { 1,2,

                   2,1,

                   1,3,

                   3,4,

                   4,2 };

    for (int i = 0; i < 5; i++)

        cout << a[i][0] << " " << a[i][1] << "\n";

    cout << "input 2 cities\n";

    cin >> k1;

    cin >> k2;

    cout << k1 << " " << k2 << "?\n";

    int p = 0;

    for (int i = 0; i < 5; i++)

    {

        if ((a[i][0] == k1) && (a[i][1] == k2)) p = 1;

    }

    if (p == 1) cout << "yes!"; else cout << "no :(";

    for (int i = 0; i < 5; i++)

    for (int j= 0;j<5;j++)

    {

        if ((a[i][0] == k1) && (a[j][1] == k2) && (a[i][1] == a[j][0]))

            cout <<"\n" << k1 << " -> " << a[i][1] << " -> " << k2 << "\n";

    }

No comments:

Post a Comment

N-point Star in Microsoft Visual Studio Console App

#include <windows.h> #include <cmath> #include <iostream> LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,...