Posts by matheusma37 • 151 points
10 posts
-
0
votes1
answer18
viewsA: Assign the return of a method to a variable only if it is not nil
The most succinct way to write a type of non-nullity check of an object is by using variavel ||= objetivo, which is a contraction of the expression variavel = variavel || objetivo. Your code would…
rubyanswered matheusma37 151 -
0
votes1
answer30
viewsA: I need at least one of these fields to be marked
You can add a Javascript script to validate your requirement. Something like: function validarCheckGroup(){ if(document.querySelectorAll('input[type="checkbox"]:checked').length == 0){…
-
1
votes1
answer79
viewsA: How do I access the name of a class instance to use later?
Your Classroom class seems kind of lazy or "useless", since it only serves to add students, maybe it is a better way to use a dictionary and have the name of the room as a key. Something like that:…
pythonanswered matheusma37 151 -
0
votes1
answer401
viewsA: Hangman Game - Hit Check
I took your code and changed a few things, check the changes and add/modify whatever you think you need in your original. Edit.: I added comments to facilitate the location of the changes. from…
pythonanswered matheusma37 151 -
1
votes4
answers365
viewsA: Repetition for calling variables
I’m not sure I understand your doubt, but from what I understand you could use a dictionary this way: d = {'f1':1,'f2':2,'f3':3,'f4':4} for x in range(1,5): print('{0} => {1}'.format('f'+str(x),…
-
1
votes2
answers115
viewsA: Warnings interfere with the program?
Warning has already said what the problem is, you have defined the function return type as an int, but you are trying to return a pointer to int, change from int proximo_da_media(int *vec, int dim)…
canswered matheusma37 151 -
1
votes1
answer2307
viewsA: How to use atof in C
The atof function is used to convert a string to a double. Strings in C end with ' 0' and when you do atof(stack[i]) the program does not find ' 0', which would indicate that it is a string, and…
canswered matheusma37 151 -
2
votes1
answer42
viewsA: Determine the position where the highest value rise occurs in an array
There are some flaws in your code, for example: the difference could already be initialized as difference = tab[1] - tab[0] and pos = 1; another thing is the use of *(tab+i), in C vectors are…
canswered matheusma37 151 -
1
votes2
answers887
viewsA: Split double chained list with head
I only looked at the two functions that you quoted, so I know if you have something else to change, but in the right function it should be for(i=0; i < n; i++) and in the left one it should be…
canswered matheusma37 151 -
2
votes1
answer2210
viewsA: How to make my code read in UTF-8 in C?
You can put the ASCII code directly into the printf or vc can add the locale library. h and add the setlocale line (LC_ALL, ""); at the beginning of the code
canswered matheusma37 151