Posts by Andrey França • 2,313 points
34 posts
-
2
votes1
answer100
viewsA: Create a 2D vector from a 1D vector in Python
You can do something like this: b = [a[i:i+2] for i in range (0, len(a), 2]
-
3
votes1
answer2985
viewsQ: Std::Sort with comparison function
Studying a little about the STL I came across the function std::sort which may receive a comparison function. template< class RandomIt, class Compare > void sort( RandomIt first, RandomIt…
-
6
votes11
answers37801
viewsA: Compute sum of digits of a number
In order for your algorithm to work, you need to take the last digit of the number, and store this value somewhere, then remove this number from the original digit, and do so while you have digits…
pythonanswered Andrey França 2,313 -
23
votes4
answers4098
viewsA: What is pythonic code?
The idioms of a programming language are defined by its users. The Python community has designed and has been using the adjective pythonic to describe any code that follows a particular style.…
-
10
votes6
answers42162
viewsA: Removing duplicate elements in a python list
A function pythonica to solve this problem would: def remove_repetidos(lista): l = [] for i in lista: if i not in l: l.append(i) l.sort() return l lista = [1, 1, 2, 1, 3, 4, 3, 6, 7, 6, 7, 8, 10 ,9]…
-
12
votes9
answers23719
viewsA: Inverting sequence (PYTHON 3)
If you want to have a Pythonic style of programming, you can do so: To read the data you can consider the example of our friend Arcashaid. Following with the inverter part of the list, see how…
pythonanswered Andrey França 2,313 -
10
votes2
answers559
viewsQ: Binary Search Tree vs Sorted List
Consider an unbalanced binary search tree and an ordered vector list. Which of the two structures is best suited to perform a search for any element.
casked Andrey França 2,313 -
8
votes3
answers918
viewsQ: Parallelism and Simultaneity
Reading a few things on the subject, I realized they are not the same thing, so I would like to find out: What’s the difference between Parallelism and Simultaneity in proceedings?…
-
18
votes1
answer1939
viewsQ: Computational Geometry: Determine nearest neighbor
Is there any algorithm to solve the following problem: Given a set of points in R² and taking a k point, determine the nearest n neighbors of k.
algorithmasked Andrey França 2,313 -
2
votes1
answer109
viewsQ: Library similar to Boost and STL in C
Is there a library similar to Boost and STL C++ with data structures, etc., in C?
-
10
votes1
answer4477
viewsQ: What does Traceback mean?
When creating some basic programs in Python, I occasionally come across errors that bring the word traceback, so I was curious to find out what traceback means.
-
10
votes1
answer2100
viewsQ: Difference between Std::list, Std::vector and Std:array
All are containers used for data guards in a sequential manner, but what are the main differences between them?
-
7
votes1
answer827
viewsQ: Copy a numpy.array without modifying the original
Given a numpy.array as the next: r = np.arange(36) r.resize(6, 6) Which results in: array([[ 0, 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,…
-
25
votes4
answers4174
viewsQ: What is the meaning of the operator ( * ) asterisk?
In C this operator is used in pointer type variables. However, in Python I don’t know which way, and why to use it. Therefore, what is the meaning of the operator (*) in the Python language?
-
1
votes2
answers560
viewsA: How to create shortcut to open a Jmenu?
Take this example, I think it will suit you: JMenu actionMenu = new JMenu("Actions"); actionMenu.setMnemonic(KeyEvent.VK_A); Where the menu will be accessed with the keys Alt+To Att.…
-
3
votes2
answers840
viewsA: How to know the number of files in a folder using Java?
Create an instance of the File class containing the path to which you want to get the total number of files. File pasta = new File("/caminho/do/diretorio"); Now just create an array with the files…
-
5
votes1
answer147
viewsQ: Is it possible to "simulate" C++ Templates in C?
Taking a stack type data structure with array for example: typedef struct stack_s { int top; int item[STACK_MAX_SIZE]; } stack_t; Doubt appears when for some reason I want to use a stack with…
-
2
votes1
answer266
viewsA: Sublime Text 3 - Headers autocomplete in the directory
Easyclangcomplete Autocomplete plugin for C++ language. You will find what you want in the configuration include_dirs Which will search for external libraries such as Boost, Ros, Eigen, OpenCV,…
-
2
votes2
answers922
viewsA: How to use an existing variable as a counter
It may be interesting to make an error handling in case the user enters with a valve that will exceed the size of the String, for example choose the letter Y and show 20 elements. I didn’t do it…
-
3
votes1
answer262
viewsA: Syntax error C
Its headquarters has been declared as Matrix; but not only on the line 101 as well as in 108 and 109 we see calling matrix, therefore the mistake if(matrix[i][0] == matrix[i][1] &&…
canswered Andrey França 2,313 -
3
votes1
answer321
viewsA: Doubt in a program in C!!! Simply chained list!
Initialize the list It is possible to easily check some implementation errors as in the function incializar, where you do not allocate memory for pointers. See an example of how such a function can…
canswered Andrey França 2,313 -
1
votes1
answer818
viewsQ: Difference between void and void*
What is the difference between void* and void as type of return of a function? Example 1: void *func_nome(int param){ ... } Example 2: void func_nome(int param){ ... }…
-
0
votes2
answers281
viewsA: Doubt: I did not understand why of continuation
As presented by José X. there are not only errors in the data entry, but also in the logic of the program. You can see an example of the same program in Ideone…
canswered Andrey França 2,313 -
2
votes3
answers1650
viewsA: How to highlight text (change color) in ANSI C
If you are using the Operating System Windows, you can include the library windows.h and use: typedef enum{BLACK,BLUE,GREEN,CYAN,RED,MAGENTA,BROWN,LIGHTGRAY,DARKGRAY,…
canswered Andrey França 2,313 -
3
votes1
answer972
viewsQ: How do they represent complex numbers in C?
How to represent a complex number z = x + yi?
-
4
votes2
answers279
viewsA: Problem with Struct and Function in C
In the struct declaration provided, the data ano, km and preco are vectors and not just a given as I think it should be. To simplify the statement would look like this: struct fichacarro { char…
-
9
votes2
answers235
viewsQ: What does the _t suffix mean and when to use it?
I see in many codes some variables with the suffix _t. There are a lot of examples in the standard C library like size_t, int32_t, mbstate_t. What is the use, and when to use this suffix?…
-
9
votes1
answer2572
viewsQ: Makefile: what is it, and what is the purpose?
I am wanting to stop using IDE, and a friend advised me to use a Makefile for my programs, so: What is a Makefile? What is your purpose?
-
4
votes3
answers451
viewsQ: Is the Std::map structure in C++ a tree?
I know that every element of the structure is represented by a key and a datum, but I don’t see it as a tree, and I read somewhere that it’s a tree.
c++asked Andrey França 2,313 -
3
votes1
answer57
viewsA: Why is the image I painted on the canvas disappearing?
Hello, that would help you a little: public static void main(String[] args){ JanelaDesenho jd = new JanelaDesenho(); jd.setVisible(true); while(true){ desenhar(); } } However, I have some…
-
3
votes1
answer74
viewsA: Doubts in the resolution of an exercise using while or for
Hello, your doubt is not so clear, try to present a piece of the code you have. It follows an algorithm that solves the question (according to what I understood of your question) by grouping 2 in 2,…
canswered Andrey França 2,313 -
3
votes1
answer260
viewsA: How to use sdl in Clion
The best way is to use Findsdl2.cmake download it and put it in the same project folder: You can find it here: https://github.com/brendan-w/collector/blob/master/cmake/FindSDL2.cmake…
-
0
votes1
answer2454
viewsQ: Intellij IDE Can’t find JDK
It already enters a standard java directory in /usr/lib/jvm/ but cannot find jdk in any folder within this directory…
-
1
votes1
answer1009
viewsQ: Logic for Cobrinha game
Hello I’m wanting to make a game of the C cover using the curses library, I started, but I’m not finding a logic to draw the Snake on the screen when the user presses the arrows, I want to know what…
casked Andrey França 2,313