Alors voilà j'ai un gros soucis avec mon code. Je ne comprends pas pourquoi mon programme plante au niveau de la création du tableau de la montagne... Est-ce que quelqu'un pourrait m'aider s'il vous plaît ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #include <iostream> #include "econio.h" #include <ctime> using namespace std; /**************************************** ** Structures et variables globales ** ****************************************/ int GNA_nbr=0; /**************************************** ** Prototype des fonctions ** ****************************************/ void AfficherCiel(int* tab_Ciel, int taille); void AfficherSol(int* tab_Sol, int taille); //void AfficherMontagne(int* tab_Montagne, int taille); int* CreationCiel(int n); int* CreationSol(int n); int* CreationMontagne(int n); /**************************************** ** Programme principal ** ****************************************/ int main () { int* tab_Sol=NULL; int* tab_Ciel=NULL; int* tab_Montagne=NULL; int n=80; CreationCiel(n); AfficherCiel(tab_Ciel, n); CreationSol(n); AfficherSol(tab_Sol, n); CreationMontagne(n); //AfficherMontagne(tab_Montagne,n); } /**************************************** ** Énoncé des fonctions ** ****************************************/ void AfficherSol(int* tab_Sol, int taille) { int* pt; for(int i=0;i<6;i++) { for(pt=tab_Sol;pt<tab_Sol+taille;pt++) { textbackground(GREEN); cout << " "; } } } void AfficherCiel(int* tab_Ciel, int taille) { int* pt; for(int i=0;i<18;i++) { for(pt=tab_Ciel;pt<tab_Ciel+taille;pt++) { textbackground(BLUE); cout << " "; } } } /*void AfficherMontagne(int* tab_Montagne, int taille) { int* pt; }*/ int* CreationSol(int n) { int* pt; int* tab_Sol; tab_Sol=(int*)calloc(n,sizeof(int)); return tab_Sol; } int* CreationCiel(int n) { int* pt; int* tab_Ciel; tab_Ciel=(int*)calloc(n,sizeof(int)); return tab_Ciel; } int* CreationMontagne(int n) { int* pt; int* tab_Montagne; if(GNA_nbr==0) { srand((unsigned)time(NULL)); GNA_nbr++; } for(int i=0; i<n;i++) *pt=rand()%18; return tab_Montagne; }
Partager