- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
#include <stdio.h>
#include <ctype.h>
unsigned int wordsCount(const char *str);
int main(int argc, char *argv[]) {
char *chr;
if(argc != 2)
return 255;
puts(argv[1]);
if(wordsCount(argv[1]) > 1) {
chr = argv[1];
while(*chr) {
if (*chr == '*')
*chr = '3';
if (*chr == '+')
*chr = '1';
if (*chr == '-')
*chr = '2';
chr++;
}
}
puts(argv[1]);
return 0;
}
unsigned int wordsCount(const char *str) {
unsigned int wordsCount = 0;
char isWord = 0;
while(*str) {
if(isalpha(*str)) {
isWord = 1;
} else if(isWord) {
wordsCount++;
isWord = 0;
}
str++;
}
if(isWord)
wordsCount++;
return wordsCount;
}
Комментарии (0) RSS
Добавить комментарий