fix dm2
This commit is contained in:
parent
7f93a91a7b
commit
2e012a29c4
13
dm2/dm2.c
13
dm2/dm2.c
@ -1,4 +1,5 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -33,7 +34,8 @@ int ecartmin(int t[], int size) {
|
||||
|
||||
// Returns 0 if no integer has been detected
|
||||
int extraire(char str[]) {
|
||||
while (*str != '-' && (*str <= '0' || *str >= '9')) {
|
||||
while ((*str != '-' || (str[1] <= '0' || str[1] >= '9')) &&
|
||||
(*str <= '0' || *str >= '9')) {
|
||||
if (*str == 0) {
|
||||
return 0;
|
||||
}
|
||||
@ -72,15 +74,15 @@ double sommemajo(double t[], int size) {
|
||||
|
||||
// Only works with ASCII
|
||||
int nbdiff(char str[]) {
|
||||
int chars[126] = {0};
|
||||
bool chars[126] = {false};
|
||||
while (*str) {
|
||||
chars[*str - 1] += 1;
|
||||
chars[*str - 1] = true;
|
||||
str += 1;
|
||||
}
|
||||
int count = 0;
|
||||
char c = 1;
|
||||
while (c < 126) {
|
||||
count += chars[c] > 0;
|
||||
count += chars[c];
|
||||
c += 1;
|
||||
}
|
||||
return count;
|
||||
@ -117,7 +119,8 @@ bool palindrome2(char str[]) {
|
||||
int sommeentiers(char str[]) {
|
||||
int count = 0;
|
||||
while (true) {
|
||||
while (*str != '-' && (*str <= '0' || *str >= '9')) {
|
||||
while ((*str != '-' || (str[1] <= '0' || str[1] >= '9')) &&
|
||||
(*str <= '0' || *str >= '9')) {
|
||||
if (*str == 0) {
|
||||
return count;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user