Megoldások - 2025. modell (2024. nov.)

Segítség pszeudokód-átíráshoz (fordítások):

    ha - dacă
    amíg - cât timp
    minden - pentru / for
    végezd el ... amíg - execută ... cât timp
    ismételd ... ameddig - repetă ... până când

    amíg (cât timp, while)
        akkor ismétel, ha a felt. igaz
        (akár elől, akár hátul)

    ameddig (până când, until)
        akkor ismétel, ha a felt. hamis
        (akár elől, akár hátul)

II.3

1
2
3
4
5
6
7
struct epoca {
    int anFabricatie;
    struct {
        int zi;
        char luna[16];
    } expo;
} m;

III.1

András-féle:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
using namespace std;

int paroskivetel(int n)
{
    int eredmeny = 0, p = 1;
    while (n > 0)
    {
        int c = n % 10;
        if (c % 2 == 0 && c != 0)
        {
            eredmeny=eredmeny +(c * p);
            p *= 10;
        }
        n /= 10;
    }
    return eredmeny;
}

int oglindit(int n)
{
    int ford=0;
    while (n > 0)
    {
        ford = ford * 10 + n % 10;
            n /= 10;
    }
    return ford;
}

void pao(int x, int y, int &rez)
{
    int a = paroskivetel(x);
    int b = paroskivetel(y);
    if (a == oglindit(b))
        rez = 1;
    else
        rez = 0;
    if(a==0&&b==0)
        rez=0;
}

int main()
{
    int rez;
    pao(460,6431,rez);
    cout<<rez<<endl;
    pao(121,2001,rez);
    cout<<rez<<endl;
    pao(111,10001,rez);
    cout<<rez<<endl;
    return 0;
}

Másképp:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
void pao(int x, int y, int &rez)
{
    int ujx = 0, p = 1;
    while (x > 0)
    {
        int c = x % 10;
        if (c % 2 == 0 && c != 0)
        {
            ujx = ujx +(c * p);
            p *= 10;
        }
        x /= 10;
    }

    int ujy = 0;
    while (y > 0)
    {
        int c = y % 10;
        if (c % 2 == 0 && c != 0)
        {
            ujy = ujy*10 + c;
        }
        y /= 10;
    }

    if (ujx == ujy && ujx != 0)
        rez = 1;
    else
        rez = 0;
}

III.2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
using namespace std;

int main()
{
    int k, n;
    cin >> k >> n;

    int t[100][100] = {};

    /*
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            t[i][j] = (k+1)*i - j + k;
    */

    for (int i = 0; i < n; i++)
        t[i][i] = (i+1)*k;

    /*for (int i = 0; i < n; i++) {
        int ertek = (i+1)*k - 1;

        for (int j = i+1; j < n; j++) {
            t[i][j] = ertek;
            ertek--;
        }
    }*/

    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            t[i][j] = t[i][j-1] - 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = i-1; j >= 0; j--) {
            t[i][j] = t[i][j+1] + 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++)
            cout << t[i][j] << " ";

        cout << endl;
    }

    return 0;
}