Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- //#include "riesenie4.h"
- #ifndef _RIESENIE_H_
- #define _RIESENIE_H_
- #endif
- const int DUMMY_INT = -999;
- const bool DUMMY_BOOL = false;
- char DUMMY_CHARS[] = "";
- const unsigned int MAX = 256;
- //pomocne funkcie
- bool isDelimiter(const char *c) {
- return (*c == ' ' || *c == '.' || *c == ',' || *c == ';'
- || *c == '?' || *c == '!' || *c == ':' || *c == '-');
- }
- //1. uloha
- int numberOfWords(const char *text) {
- if (text == nullptr) {
- return 0;
- }
- int num = 0;
- bool word = false;
- for (const char *i = text; *i != '\0';++i) {
- if (isDelimiter(i)) {
- word = false;
- }
- else if (!word) {
- word = true;
- ++num;
- }
- }
- return num;
- }
- const char *pointerToNthWord(const char *text, int order) {
- if (text == nullptr) {
- return "";
- }
- int num = 0;
- bool word = false;
- for (const char *i = text; *i != '\0'; ++i) {
- if (isDelimiter(i)) {
- word = false;
- }
- else if (!word) {
- word = true;
- if (order == num) {
- return i;
- }
- ++num;
- }
- }
- return "";
- }
- //2. uloha
- char *getNthWord(const char *text, char *word, int order) { //TODO pozri funkcie strcpy a strcat
- if (word == nullptr) {
- static char empty[1] = { '\0' };
- return empty;
- }
- if ((text == nullptr) || (order > numberOfWords(text))) {
- *word = '\0';
- return word;
- }
- char *begin = word;
- for (const char *i = pointerToNthWord(text, order); *i != '\0'; ++i) {
- if (isDelimiter(i)) {
- break;
- }
- else {
- *begin = *i;
- begin++;
- }
- }
- *begin = '\0';
- return word;
- }
- //3. uloha
- char *listOfSelectedWords(const char *text, char *output, const int *listOfOrders, int numberOfOrders) {
- return DUMMY_CHARS;
- }
- //4.uloha
- void sortAccordingToAsciiValues(char **listOfWords, int count) {
- }
- void sortWithSmallLetters(char **listOfWords, int count) {
- }
- //5.uloha
- void sortWithSmallAndCh(char **listOfWords, int count) {
- }
- char *sortAccordingToFuncion(const char *text, char *output, void sortingFunction(char **arrayOfText, int count)) {
- return DUMMY_CHARS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement