(СИ)Требуется выделить в строке-предложении s все слова, разделенные символами-разделителями «_.,;:\n\t!?» и напечатать слова, содержащие хотя бы одну цифру.
Вот, что я написала, но код не работает: (возможно стоит использовать функцию isdigit()
#define _CRT_SECURE_NO_WARNINGS
#define DELIMITERS ".,:;\n\t!?"
#include
#include
#include
#include
#include
using namespace std;

int main()
{
setlocale(LC_ALL, "rus");
char s[100];
char* word;
int i, k=0;
int(isdiget(int c));
fgets(s, 100, stdin);
word = strtok(s, DELIMITERS);
while (word != NULL) {
puts(word);
word = strtok(NULL, DELIMITERS);
}
for (i = 0; s[i]; i++) {
char c;
c = s[i];
if( (c > 0) && (c < 9)) {
k++;
}
}
cout << k;
return 0;
}
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.