Help C++ dynamic programming

Hi guys, I'm working at a project about a popular italian game, but I've got any problem in the code: I want to get it better with vector or list for the imagepath, and than I want to modified this code, with some better function...thanks

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
void generaCarte()
{
    carte[0].setImagePath("2c.bmp");
    carte[1].setImagePath("3c.bmp");
    carte[2].setImagePath("4c.bmp");
    carte[3].setImagePath("5c.bmp");
    carte[4].setImagePath("6c.bmp");
    carte[5].setImagePath("7c.bmp");
    carte[6].setImagePath("jc.bmp");
    carte[7].setImagePath("qc.bmp");
    carte[8].setImagePath("kc.bmp");
    carte[9].setImagePath("ac.bmp");
    carte[10].setImagePath("2d.bmp");
    carte[11].setImagePath("3d.bmp");
    carte[12].setImagePath("4d.bmp");
    carte[13].setImagePath("5d.bmp");
    carte[14].setImagePath("6d.bmp");
    carte[15].setImagePath("7d.bmp");
    carte[16].setImagePath("jd.bmp");
    carte[17].setImagePath("qd.bmp");
    carte[18].setImagePath("kd.bmp");
    carte[19].setImagePath("ad.bmp");
    carte[20].setImagePath("2f.bmp");
    carte[21].setImagePath("3f.bmp");
    carte[22].setImagePath("4f.bmp");
    carte[23].setImagePath("5f.bmp");
    carte[24].setImagePath("6f.bmp");
    carte[25].setImagePath("7f.bmp");
    carte[26].setImagePath("jf.bmp");
    carte[27].setImagePath("qf.bmp");
    carte[28].setImagePath("kf.bmp");
    carte[29].setImagePath("af.bmp");
    carte[30].setImagePath("2p.bmp");
    carte[31].setImagePath("3p.bmp");
    carte[32].setImagePath("4p.bmp");
    carte[33].setImagePath("5p.bmp");
    carte[34].setImagePath("6p.bmp");
    carte[35].setImagePath("7p.bmp");
    carte[36].setImagePath("jp.bmp");
    carte[37].setImagePath("qp.bmp");
    carte[38].setImagePath("kp.bmp");
    carte[39].setImagePath("ap.bmp");
    for(int i=0;i<40;i++)
    {
        if(i>=0&&i<10)
        {
            carte[i].setSeme(1);
        }
        else if(i>9&&i<20)
        {
            carte[i].setSeme(2);
        }
        else if(i>19&&i<30)
        {
            carte[i].setSeme(3);
        }
        else if(i>29&&i<40)
        {
            carte[i].setSeme(4);
        }
        if(i<6)
        {
            carte[i].setPunteggio(0);
        }
        else if(i>9&&i<16)
        {
            carte[i].setPunteggio(0);
        }
        else if(i>19&&i<26)
        {
            carte[i].setPunteggio(0);
        }
        else if(i>29&&i<36)
        {
            carte[i].setPunteggio(0);
        }
        carte[i].setValNum((i%10)+1);
    }
    carte[1].setValNum(10);
    carte[11].setValNum(10);
    carte[21].setValNum(10);
    carte[31].setValNum(10);
    carte[9].setValNum(11);
    carte[19].setValNum(11);
    carte[29].setValNum(11);
    carte[39].setValNum(11);
    carte[6].setValNum(7);
    carte[16].setValNum(7);
    carte[26].setValNum(7);
    carte[36].setValNum(7);
    carte[7].setValNum(8);
    carte[17].setValNum(8);
    carte[27].setValNum(8);
    carte[37].setValNum(8);
    carte[8].setValNum(9);
    carte[18].setValNum(9);
    carte[28].setValNum(9);
    carte[38].setValNum(9);
    carte[1].setPunteggio(10);
    carte[11].setPunteggio(10);
    carte[21].setPunteggio(10);
    carte[31].setPunteggio(10);
    carte[9].setPunteggio(11);
    carte[19].setPunteggio(11);
    carte[29].setPunteggio(11);
    carte[39].setPunteggio(11);
    carte[6].setPunteggio(2);
    carte[16].setPunteggio(2);
    carte[26].setPunteggio(2);
    carte[36].setPunteggio(2);
    carte[7].setPunteggio(3);
    carte[17].setPunteggio(3);
    carte[27].setPunteggio(3);
    carte[37].setPunteggio(3);
    carte[8].setPunteggio(4);
    carte[18].setPunteggio(4);
    carte[28].setPunteggio(4);
    carte[38].setPunteggio(4);
}
So what is your question exactly? I don't understand.
In my terminology "dynamic programming" is something different.

Cards? {"c", "d", "f", "p"} and {"2", .. "a"}. Two ranges, two loops to generate the combinations.

Your for-loop initializes every Punteggio to 0, even though you have long if..else.

Compare your setSeme and setValNum results of your for-loop.

1
2
3
4
5
6
7
const int offset = 1;
const int stride = 10;
for ( int i=0; i<4 ++i )
{
  const int n = stride * i + offset;
  // use n
}



Where did the "carte" came from anyway? You do not show its type. Btw, global variables are not good.
mmmm I've got another problem: all my program give this problem:
[Linker Error] undefined reference to `readimagefile'
ld returned 1 exit status
C:\Users\Jenny\Desktop\21.05 12.3\Makefile.win [Build Error] [Output/MingW/21.05] Error 1
Linker combines binary code "object files" into the executable. It makes sure that every (function) call is linked to the code implementing that function.

Since your compiler did not stop on error, where-ever you call the readimagefile, you do have a declaration of that function as you should. However, you don't have the implementation for that function in any of the object files or libraries that you do list for the linker.

Either you do not have the code, or don't include it in the build process.
Topic archived. No new replies allowed.