Posts by Lucas Trigueiro • 664 points
27 posts
-
1
votes1
answer59
viewsA: Trash memory output function inserts in the middle of a list
The function was getting a new node and creating a new node within it, that is, it was doing the process twice. In the case of my answer I removed the node that is created by the function cria_no…
-
3
votes1
answer68
viewsA: Function insert in list
In main your function starts empty(NULL), then you call the insert function and do not update the main value, then the list remains empty. If the list is not empty, you will insert at the beginning…
canswered Lucas Trigueiro 664 -
2
votes2
answers6045
viewsA: How can I invert a simple chained list without using a previous pointer
The first function reverses the list elements and the second function reverses the start and end reference. void inverteElementos (TElemento *e, TElemento *ant){ if(e->proximo!=NULL)…
-
0
votes1
answer29
viewsA: Progressively Removing from the List
You need a helper to do the removal otherwise the list breaks void progress(List *list, int i, int j){ if(list == NULL) { printf("Lista vazia.\n"); return; } ListElmt *node = atpos(list,i-1);…
canswered Lucas Trigueiro 664 -
0
votes3
answers414
viewsA: Algorithm for distributing entries from an encyclopedia based on number of characters per day
Solving this problem is not difficult, the problem is feasibility due to computational cost. A simple way to solve: create an algorithm that generates all possible combinations and then check which…
algorithmanswered Lucas Trigueiro 664 -
2
votes1
answer842
viewsA: Function print circular list
Only changes that the stop criteria of the repeat loop will be when you get to the first one. It is also necessary to change the whilefor do, because the list already begins in the first element and…
canswered Lucas Trigueiro 664 -
3
votes2
answers1461
viewsA: Read a txt file and place each character in a position of an array in C
#include <stdio.h> //#include <iostream> //using namespace std; int main() { int a; char texto[1000]; FILE *file; file = fopen("texto.txt", "r"); if (file == NULL) { printf("Arquivo nao…
-
1
votes1
answer27
viewsA: Switch command running even without being called - C
An array of char ends with \0 then created with size 2 (one for the character and one for the \0). When passing the value to the case, I passed only the type[0], which is the necessary value. I also…
canswered Lucas Trigueiro 664 -
0
votes2
answers2149
viewsA: How to detect the largest word of a string in C?
The idea of this function below is to store in a temporary where the word begins and how long it is. Then it checks if the temporary is larger than the largest word found so far and if it is, this…
-
0
votes1
answer92
viewsA: Make a drawing as user input
Starting at the top: Any line can be formed from this pattern: (espaço)(\)(espaço)(*)(espaço)(/)(espaço) and the question is how many times each symbol should be drawn on each line. See this…
canswered Lucas Trigueiro 664 -
5
votes2
answers458
viewsA: Doubt in displacement of bits in C
This section works with the binary of the numbers, you must understand the functioning of each one: 1) The symbol "|" means "OR inclusive" and what it does is as follows:: Makes the value of the bit…
-
0
votes1
answer234
viewsA: Dynamically creating lists and saving their addresses (top of list)
Your code is ready now, I think there are only two lines left to solve what you ask. 1) This type of data you are doubting is a List type data. Exchange int* for:: Lista* table[M_SIZE]; So each…
-
0
votes1
answer5263
viewsA: String chained list (character array) in C
The code is generating the word in a variable char word and is being passed on to the function insereLista. Also added a function to print the chained list, I believe you can adapt to your goal.…
-
2
votes1
answer108
viewsA: Linked list main help
I made a main() testing the functions. I also made some minor corrections to the code and are commented inside the code. #include <stdio.h> #include <stdlib.h> #include <stddef.h>…
canswered Lucas Trigueiro 664 -
1
votes2
answers71
viewsA: Insert linked list node
tipo_lista * inserir_inicio (tipo_lista * p, tipo_lista * novo_no) { novo_no -> prox = p; return novo_no; } The new_no will now be the first element, just return it. When you call the function,…
canswered Lucas Trigueiro 664 -
0
votes2
answers2484
viewsA: How to store contacts from the agenda I created in an array array and list them? C
Here are some tips for your code and I gave some examples modifying the original code. Tips: 1) Try not to create too large functions. The more modularized your code gets, it will be easier to…
-
1
votes1
answer638
viewsA: How to run a . bat file from a C algorithm?
It’s very simple, if you’re in the same directory just call it that: system("nome.bat"); or you can call with the full path too, for example: system("C:\\Users\\Lucas\\Desktop\\teste.bat");…
canswered Lucas Trigueiro 664 -
0
votes1
answer94
viewsA: Why does code Blocks compile using g++ in a project configured as "C"
Have you already used codeblocks or installed it now? Give more details of your problem. Check that the compiler is selected correctly. After you have selected C, click on next will appear the…
-
0
votes1
answer87
viewsA: Code error - Brazilian Computer Olympiad, C
I read the problem statement, but with my interpretation I could not understand its logic. I will summarize what I understood of the issue and how I did to solve the problem. We know that X + Y +…
canswered Lucas Trigueiro 664 -
1
votes1
answer2197
viewsA: Bubble Sort in list
The current = (*l)->prox must be inside the first loop to start over every time. The prev = prev->prox must be inside the second loop to go through the list. And the current = prev->prox…
canswered Lucas Trigueiro 664 -
3
votes1
answer164
viewsA: Doubt about simple chaining in c
Write down p->prox = lixo->prox; is the same thing as p->prox = p->prox->prox; You do this so you can remove the middle item. Ex: imagine the list 4 5 6 The 4 is the p and the 5 is…
-
1
votes2
answers1567
viewsA: Error declaration null - Unknown type name bool
In addition to error: Unknown type name 'bool'| has some other minor errors in function while (aux -> prox != NULL) Will not check the last item in the list. else { return false; } The else is…
-
0
votes2
answers153
viewsA: Print number of nodes in a list
Just modify while (aux -> prox != NULL) for while (aux != NULL) *Note: The rest is correct, do not change the counter to start at 1 because it will return a wrong value if you pass an empty list.…
-
1
votes1
answer2063
viewsA: How to find higher value Chained List C?
I implemented the missing functions: #include<stdio.h> #include<stdlib.h> #include<malloc.h> #include<conio.h> #define TAM 3 //Declaração da struct nodo typedef struct nodo {…
-
1
votes1
answer100
viewsA: Error trying to grab data from a . txt file and move to a C queue?
Your code is incomplete, so it’s difficult to answer directly, what you can do is give you a generic answer. The code below creates a queue and inserts values, which can be used as a basis to solve…
-
1
votes1
answer64
viewsA: Modify >= 2D array using pointers
It’s easier to allocate the matrix like this: int **mat; mat = (int *) malloc(row * sizeof(int)); for ( i = 0; i < row; i++ ){ mat[i] = (int * )malloc( column * sizeof(int)); } The complete code…
-
0
votes1
answer1028
viewsA: Transforming a Single List into a Double Chained List
There are only 2 corrections to be made: 1) The notes are reversed LD* insereLD(LD* l, int valor){ LD* novo = (LD*)malloc(sizeof(LD)); novo->info = valor; /* ant e prox estão invertidos…