Untitled

 avatar
unknown
plain_text
2 years ago
1.1 kB
8
Indexable
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include "ROW.h"

using namespace std;

// Default constructor
ROW::ROW()
{
	this->row = new char[500];
}

// Constructor of initializing 
ROW::ROW(char row[])
{
	this->row = row;
}

// Copying constructor
ROW::ROW(const ROW& rrr)
{
	this->row = rrr.row;
}

// Destructor
ROW::~ROW()
{
	delete[] row;
}

// Row getter
void ROW::getRow() const
{
	cout << "\n " << this->row << "\n";
}

// Lexems getter and word's lenght counter
int ROW::getLexems(char row[]) const
{
	char* tk;
	int* arr = new int;
	char spt[] = ",.?!';:[]{}/><~`@#$%^&*()_-+= ";

	int i = 1;

	tk = strtok(row, spt);

	while (tk != NULL)
	{
		cout << i << " word - " << tk /*<< " "*/<< " - contains " << strlen(tk) << " symbols " << endl;
		arr[i - 1] = static_cast<int>(strlen(tk));
		tk = strtok(NULL, spt);
		i++;
	}

	int tmp = arr[0];

	if (i - 2 >= 0)
	{
		for (int j = 0; j < i - 2; j++)
		{
			if (tmp >= arr[j + 1]) tmp = tmp;
			else tmp = arr[j + 1];
		}
	}
	
	cout << "\n The longest word has " << tmp << " symbols" << endl;

	return 0;
}
Editor is loading...