#include
#include
#include
#include
#include
void printTable(int , int , char**); //wyswietla tablice Matrixa
void moveRovs (int , int , char**); //opadanie rzedow
void randomFirstRov (int , int , char**); //losowo wypelnia pierwszy rzad
void showWord (int , int , char**, char*, int);
char rnd (); //losuje znak z tablicy ASCII
void MatrixG(int ,int ,char**);
int main(int count, char** args)
{
int x, y; //x=ilosc kolumn, y= ilosc wierszy
char** Matrix;
srand(time(NULL));
if(count==3)
{
x = atoi(args[1]);
y = atoi(args[2]);
}
else
{
printf("Podaj ilosc kolumn i ilosc wierszy");
scanf("%d %d", &x, &y);
}
//alokacja pamieci dla Matrixa
Matrix = (char**) malloc(sizeof(Matrix)*y);
for(int i=0; i
*(Matrix +i) = (char*) (malloc(sizeof(char)*x));
for(int j=0; j
*(*(Matrix+i)+j) = rnd();
}
}
system("color 02");
MatrixG(x, y, Matrix);
free(Matrix);
return 0;
}
void printTable(int x, int y, char** Matrix)
{
for(int i=0; i
for(int j=0; j
if(*(*(Matrix+i)+j) == '0')
{
printf(" ");
}
else
{
printf("%c ", *(*(Matrix+i)+j));
}
}
printf("\n");
}
}
char rnd()
{
//zakres cyfr w tabeli ASCII
int min=48;
int max=57;
return (char) ((rand() % (max-min)) + min);
}
void moveRovs (int x, int y, char** Matrix)
{
for(int i=y; i>1; i--)
{
memcpy(*(Matrix+i-1),*(Matrix+i-2), sizeof(**Matrix)*x);
}
randomFirstRov(x, y, Matrix);
}
void randomFirstRov (int x , int y , char** Matrix)
{
for(int i=0; i
*(*Matrix+i)=rnd();
}
}
void showWord (int x, int y, char** Matrix, char* word, int position)
{
int k = 0; //zmienna do iterowania liter w s³owie
for(int i=0; i
for(int j=0; j
if(j == position) //je¿eli jesteœmy na podanej pozycji to wstawia literê ze s³owa zamiast losowaæ cyfre
{
*(*Matrix+j)=word[k];
k++;
continue;
}else
{
*(*Matrix+j) = rnd();
}
}
for(int j=y; j>1; j--)
{
memcpy(*(Matrix+j-1),*(Matrix+j-2), sizeof(**Matrix)*x);
}
}
MatrixG(x, y, Matrix);
}
void MatrixG(int x, int y, char** Matrix)
{
char letter;
while(1 && letter!='t')
{
system("cls");
printTable(x, y, Matrix);
moveRovs(x, y, Matrix);
if(kbhit())
{
letter=getch();
}
system("ping 127.0.0.1 -n 1 > nul");
//for(int i=0; i<100000000; i++){}
}
char word[] = "teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeest";
int position;
//printf("Podaj slowo");
// scanf("%s", word);
printf("podaj pozycje", &position);
scanf("%d", &position);
showWord(x, y, Matrix, word, position);
}