Posts by Nefisto • 136 points
9 posts
-
1
votes0
answers65
viewsQ: How to change stdout back to default?
In case I change the stdin and stdout for some . specific txt, however after changing do not know how to make it return to the normal stdout(in case the prompt), I change through the freopen as in…
-
0
votes2
answers121
viewsA: Chained lists
I’ll try to help: SHORT answer, follow the corrected code, put /// on the lines on which I made some change: #include <stdio.h> #include <stdlib.h> struct cel { int valor; struct cel *…
-
0
votes4
answers5419
viewsA: Vector without repeated numbers in C
#include <stdio.h> #define TAM_VETOR 5 int main() { int vetor[TAM_VETOR] = {0};//zera tudo que tive la dentro int qtdInseridos = 0;//Quantos numeros ja foram inseridos int n;//valor que o cara…
-
2
votes2
answers1005
viewsA: How to get all the digits of a variable in C?
#include <stdio.h> int Divisibilidade( int num ) { int res = 0; while( num > 0 ) { res += num % 10; num /= 10; } if(res > 9) return Divisibilidade( res ); else return (res%3); } int…
-
1
votes2
answers189
viewsA: How to test if a string is a number in the C language?
See if that’s what you wanted. #include <stdio.h> int IsNumber( char input[] ) { register int i; int flagVirgula = 0; for(i = 0; input[i]; i++) { if( !i && !(input[i] - '-') )//Numero…
-
0
votes1
answer118
viewsA: Print a square where prime number positions receive a "#" and the others receive a "_"
#include <stdio.h> #include <math.h> int Primo(int n) { if( n == 2 ) return 1; if( !(n%2) || n == 1 ) return 0; register int i; int maxP = (int)ceil(sqrt((double)n)); for(i = 3; i <=…
-
0
votes2
answers1435
viewsA: C - Print the N-esimo prime number
void nesimo_primo(int n){ int a, primo, div, nesimo; primo = 1; //primo se inicia com 1 a = 1; if(n == 1) nesimo = 2; else { for(nesimo = 3; nesimo <= 1000; nesimo++) { for(div = 2; div <=…
-
0
votes1
answer147
viewsA: Dynamic List with void pointer insert at start
You are not checking if you are the first element of the list to be inserted. int Insere_InicioLi (t_lista *Lista, void *x) { t_nodeL *No = Cria_NoLista(); No->val = x; if(Lista->qtde == 0) {…
-
2
votes1
answer1049
viewsA: How do I write a loop to read a file to a C struct array?
I chose to redo it because I couldn’t follow its algorithm very well. Some things didn’t make much sense. With your knowledge, I believe that the reading of the code will be self-explanatory. Only…