fix dm2 (again)

This commit is contained in:
Arkitu 2025-10-06 20:03:17 +02:00
parent ac8499addb
commit 4820893366
2 changed files with 9 additions and 8 deletions

View File

@ -34,8 +34,8 @@ int ecartmin(int t[], int size) {
// Returns 0 if no integer has been detected
int extraire(char str[]) {
while ((*str != '-' || (str[1] <= '0' || str[1] >= '9')) &&
(*str <= '0' || *str >= '9')) {
while ((*str != '-' || (str[1] < '0' || str[1] > '9')) &&
(*str < '0' || *str > '9')) {
if (*str == 0) {
return 0;
}
@ -119,8 +119,8 @@ bool palindrome2(char str[]) {
int sommeentiers(char str[]) {
int count = 0;
while (true) {
while ((*str != '-' || (str[1] <= '0' || str[1] >= '9')) &&
(*str <= '0' || *str >= '9')) {
while ((*str != '-' || (str[1] < '0' || str[1] > '9')) &&
(*str < '0' || *str > '9')) {
if (*str == 0) {
return count;
}

View File

@ -1,5 +1,6 @@
// This is a modified version of the dm that sticks with what
// we are allowed to do (no fancy pointer arithmetic)
#include "test_dm1.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@ -37,8 +38,8 @@ int ecartmin(int t[], int size) {
// Returns 0 if no integer has been detected
int extraire(char str[]) {
int i = 0;
while ((str[i] != '-' || (str[i + 1] <= '0' || str[i + 1] >= '9')) &&
(str[i] <= '0' || str[i] >= '9')) {
while ((str[i] != '-' || (str[i + 1] < '0' || str[i + 1] > '9')) &&
(str[i] < '0' || str[i] > '9')) {
if (str[i] == 0) {
return 0;
}
@ -125,8 +126,8 @@ int sommeentiers(char str[]) {
int count = 0;
int i = 0;
while (true) {
while ((str[i] != '-' || (str[i + 1] <= '0' || str[i + 1] >= '9')) &&
(str[i] <= '0' || str[i] >= '9')) {
while ((str[i] != '-' || (str[i + 1] < '0' || str[i + 1] > '9')) &&
(str[i] < '0' || str[i] > '9')) {
if (str[i] == 0) {
return count;
}