tuto mas plne funkcny kod s ukazovatelmi, je univerzalny, troska zlozity, ale coolovejsi, na vysokej urovni bez OPP. Koli tebe som musel obetovat skoro 15 minut. Ak to mas ulohu do skoly na strednej tak za toto mas 1 s pochvalou
Kód:
#include <iostream>
#include <stdio.h>
using namespace std;
void SmazMrizku(char** pomM, const int W, const int H)
{
for(int i = 0; i < H; i++)
for(int j = 0; j < W; j++)
pomM[i][j]= ' '; // *(pomM+j)= ' '
}
void AddStar(char** pomM, const int W, const int H)
{
pomM[W][H] = '*';
}
void VytiskniMrizku(char** pomM, const int W, const int H)
{
//cout <<(char*) pomM << endl;
for(int i = 0; i < W; i++)
{
for(int j = 0; j < H; j++){
printf("%c", pomM[i][j]);
}
printf("\n");
}
printf("\n");
}
int main() {
const int W = 8;
const int H = 8;
char** Mrizka = new char* [W];
for (int i=0; i<W; i++)
Mrizka[i] = new char [H];
SmazMrizku(Mrizka, W, H);
AddStar(Mrizka, 2, 5);
VytiskniMrizku(Mrizka, W, H);
//cout <<(char*) Mrizka << endl;
for (int i=0; i<H; i++) //
delete Mrizka[i];
delete[] Mrizka;
return 0;
}