53 lines
919 B
C++
53 lines
919 B
C++
/*
|
|
Nome: Mario
|
|
Cognome: Montanari
|
|
Classe: 3AIN
|
|
Data: 07/03/2025
|
|
|
|
es4E: Cancellare i caratteri corrispondenti alle cifre
|
|
pari che compaiono in una stringa s ricevuta in input.
|
|
Prototipo richiesto:
|
|
char *delevendigits(char * const str);
|
|
Esempio: "25dic2018" ? "5dic1"
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <cctype>
|
|
|
|
#define SIZE 100+1
|
|
|
|
using namespace std;
|
|
|
|
int isVowel(char chr);
|
|
char *delevendigits(char * const str);
|
|
|
|
int main(void) {
|
|
char str[SIZE];
|
|
|
|
cin.getline(str, SIZE);
|
|
|
|
cout << delevendigits(str);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int isVowel(char chr) {
|
|
chr = toupper(chr);
|
|
|
|
return (chr == 'A' || chr == 'E' || chr == 'I' || chr == 'O' || chr == 'U');
|
|
}
|
|
|
|
char *delevendigits(char * const str) {
|
|
int j = 0;
|
|
|
|
for (int i = 0; str[i] != '\0'; i++) {
|
|
if (!isdigit(str[i]) || (str[i] - '0') % 2 != 0) {
|
|
str[j] = str[i];
|
|
j++;
|
|
}
|
|
}
|
|
|
|
str[j] = '\0';
|
|
|
|
return str;
|
|
} |