DEV Community

Junissen
Junissen

Posted on

Where is tutorial to C?

C - OOP-language for structure, where we don't know all objects and actions (e.g. microservice with 10+ integrations or Arduino).

A = (int **)malloc(n * sizeof(int *));
    for (int i = 0; i < n; i++)
        A[i] = (int *)malloc(n * sizeof(int));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (sqrt(Vert[i] + Vert[j]) - (int)sqrt(Vert[i] + Vert[j]) < 0.001) A[i][j] = 1;
            else A[i][j] = 0;
        }
    }
Enter fullscreen mode Exit fullscreen mode
  1. Let's start to decrypte some example: * - array, **-decart array. We don't use some useful words for creating cycle
  2. Variables i/j making cycle more ordered without much descriprions
  3. Conditions if/else don't put our variables values, but initialize temporary memory 0/1 (like false/true eng)
    ofstream answerFile;
    answerFile.open(file_name);

    for (int i = 0; i < n; i++) {
        answerFile << Vert[Path[i]] << " ";
    }

    answerFile.close();
Enter fullscreen mode Exit fullscreen mode

Files - memory with undetectable type of variables (e.g. .doc/.txt/.img).
I'm using several algorithms for opening/closing files with library .

class Graph
{
private:
    std::vector <int> Vert; 
    int **A, n; 
    std::vector <int> Path; 
    std::vector <bool> Visited; 

Enter fullscreen mode Exit fullscreen mode

Don't forget creating 2 different types: .h - header file; .c/.cpp - working file. It's help compiler handle exceptions more quickly.

Class Graph defines memory area under some variables and functions. Decart array A and integer type n are identified like path of class. Fuctions Vert and Path will work inviseble to the user (Cos private path). And Visited will have values 0/1.

Top comments (0)