Pouriez vous me dire si ce code est portable...
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
#include <conio.h>
#include <mmsystem.h>
 
//-----------------------------------------------------------------------------  
void Ecran(int Mode) // parametre Mode : 1=plein ecran et 2=mode fenetre
{
     typedef BOOL WINAPI (*SetConsoleDisplayModeT)(HANDLE,DWORD,DWORD*);
     SetConsoleDisplayModeT SetConsoleDisplayMode;
 
    HINSTANCE hLib=LoadLibrary("KERNEL32.DLL");
    SetConsoleDisplayMode=(SetConsoleDisplayModeT)
       GetProcAddress(hLib,"SetConsoleDisplayMode");
 
    HANDLE h=CreateFile("CONOUT$",GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ |
       FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,0);
 
    DWORD oldmode;
 
    SetConsoleDisplayMode(h,Mode,&oldmode);
}
//-----------------------------------------------------------------------------
void aff(int x,int y)
{
  HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
  COORD pos={x,y};
  SetConsoleCursorPosition(handle,pos);  
}
//-----------------------------------------------------------------------------
 
int main()
{
  printf(" Par Pierre BLACHE...");
  Sleep(5000);
  system("cls"); 
  int x,x1,x2,x3,x4,x5,x6,x7,x8,x9,y,y1,y2,y3,y4,y5,y6,y7,y8,y9,c;
  Ecran(1);
  srand((unsigned)time(NULL));
 
  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
 
  for (x=0;x<80;x++)
  for (y=1;y<=50;y++)
  {
  c=(rand()%200)+10;
  aff(x,y);
  printf("%c",c);
  }
  y1=rand()%50;
  y2=rand()%50;
  y3=rand()%50;  
  y4=rand()%50;
  y5=rand()%50;
  y6=rand()%50;
  y7=rand()%50;
  y8=rand()%50;
  y9=rand()%50;
 
  while(1)
  {
  if (kbhit()) if(getch()==27) exit(0);
  y1++;
  y2++;
  y3++;
  y4++;
  y5++;
  y6++;
  y7++;
  y8++;
  y9++;
 
  if (y1>50){ x1=rand()%80; y1=1;}
  c=(rand()%200)+10;
  aff(x1,y1);
  printf("%c",c);
 
  if (y2>50){ x2=rand()%80; y2=1;}
  c=(rand()%200)+10;
  aff(x2,y2);
  printf("%c",c);
 
  if (y3>50){ x3=rand()%80; y3=1;}
  c=(rand()%200)+10;
  aff(x3,y3);
  printf("%c",c);
 
  if (y4>50){ x4=rand()%80; y4=1;}
  c=(rand()%200)+10;
  aff(x4,y4);
  printf("%c",c);
 
  if (y5>50){ x5=rand()%80; y5=1;}
  c=(rand()%200)+10;
  aff(x5,y5);
  printf("%c",c);
 
  if (y6>50){ x6=rand()%80; y6=1;}
  c=(rand()%200)+10;
  aff(x6,y6);
  printf("%c",c);
 
  if (y7>50){ x7=rand()%80; y7=1;}
  c=(rand()%200)+10;
  aff(x7,y7);
  printf("%c",c);
 
  if (y8>50){ x8=rand()%80; y8=1;}
  c=(rand()%200)+10;
  aff(x8,y8);
  printf("%c",c);
 
  if (y9>50){ x9=rand()%80; y9=1;}
  c=(rand()%200)+10;
  aff(x9,y9);
  printf("%c",c);
 
//  sndPlaySound("Son.wav", SND_SYNC );
 
  Sleep(20);
  }
 
  return 0;
}