diff --git a/2021/2/entrada.c b/2021/2/entrada.c index 2bd4b5c..11bed00 100644 --- a/2021/2/entrada.c +++ b/2021/2/entrada.c @@ -7,10 +7,10 @@ bool isPrime (int num) { if (num < 2) return false; - for(i = 3; i < sqrt(num); i++) + for(i = 3; i < sqrt(num); i += 2) if(num % i == 0) return false; - return 0; + return true; } void countProducts() { @@ -23,7 +23,7 @@ void countProducts() { else np++; } - if((n1 == p && n2 == np) || n1 + n2 == p || n1 + n2 == np) + if ((n1 == p && n2 == np) || n1 + n2 == p || n1 + n2 == np) printf("ROGeRIO POH DEIXAR ESSX AQUI ENTRAR QUE TA LIMPO\n"); else if (p == np && np == 0) printf("vei sem nada neah? vai gasta moh grana ai dentro\n"); @@ -33,7 +33,7 @@ void countProducts() { } int main(){ - int n; + int n = 0; for(scanf(" %d", &n); n > 0; n--) countProducts(); diff --git a/2021/2/olhos.c b/2021/2/olhos.c index 170ff9f..5052fc9 100644 --- a/2021/2/olhos.c +++ b/2021/2/olhos.c @@ -34,12 +34,11 @@ bool isRepeated (char **words, int i, int size) { int countRepetitions (char **words, int size) { int i, repetitions = 0; - for (i = 0; i < size - 1; i++) { + for (i = 0; i < size; i++) { if (isRepeated(words, i, size)) repetitions++; free(words[i]); } - free(words); return repetitions; }