.


:




:

































 

 

 

 





 

 

 

 

 

1

ӻ

8

 

 

: . 812 ________ ___.___._____ ..
       
: ________ ___.___._____ ..

 

 

2011


 

.

, , 1000 ( 70 ). DAT. , :

1) ;

2) ;

3) , .


#include "stdafx.h"

#include <iostream>

#include <string>

#include <fstream>

#include <windows.h>

#include <conio.h>

 

HANDLE hConsole;

HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

 

using namespace std;

 

void SetColor(int text, int background);

 

int _tmain(int argc, _TCHAR* argv[])

{

setlocale(0, "RUS"); //

system("mode con cols=100 lines=40"); //

SetColor(15, 0); //

 

int SizeShortWord = -1; //

int TempSize; //

bool IsFinishSearch = false; //

bool exit = false; //

bool ColorWordIsWrite = false;

 

int Symbols = 0;

 

//

string fileName = "input.dat", buffer;

ifstream InputFile(fileName.c_str());

 

// -

if (!InputFile)

{

cout << " :(\n";

system("pause");

return 1;

}

 

cout << " : \n\n";

string str; //

char ch; // ,

 

//

do

{

InputFile >> str;

Symbols += str.size();

 

cout << str;

 

TempSize = 0;

 

for (int i = 0; i < str.size(); i++)

{

if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z') || (ch >= '' && ch <= '') || (ch >= '' && ch <= ''))

{

TempSize++;

}

else

{

if (str[i] == '-' && str.size() > i + 1)

{

TempSize++;

}

else

{

break;

}

}

}

 

if ((SizeShortWord > TempSize || SizeShortWord == -1) && TempSize!= 0)

{

SizeShortWord = TempSize;

}

 

do

{

InputFile.get(ch);

 

if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch >= '' && ch <= '') || (ch >= '' && ch <= '')))

{

cout << ch;

Symbols++;

if (ch == '\n')

Symbols++;

}

else

{

if (!InputFile.eof())

InputFile.seekg(Symbols - 1);

break;

}

}

while (!InputFile.eof());

}

while (!InputFile.eof());

 

cout << "\n\n";

cout << " " << SizeShortWord << " ().\n\n";

cout << " .\n";

 

 

InputFile.clear(); // eof

InputFile.seekg(0, std::ios::beg); //

 

int NowOutWord = 0;

int OutWord = 0;

 

int NowWord;

 

do

{

_getch();

system("cls");

 

Symbols = 0;

 

cout << " : \n\n";

 

NowWord = 0;

NowOutWord = 0;

 

ch = '^';

 

//

do

{

InputFile >> str;

 

Symbols += str.size();

 

NowWord++;

 

// , ,

if (!IsFinishSearch)

{

TempSize = 0;

 

for (int i = 0; i < str.size(); i++)

{

if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= '0' && str[i] <= '9') || (ch >= '' && ch <= '') || (ch >= '' && ch <= ''))

{

TempSize++;

}

else

{

if (str[i] == '-')

{

TempSize++;

}

else

{

break;

}

}

}

 

if (TempSize == SizeShortWord)

{

 

if (NowOutWord == OutWord)

{

IsFinishSearch = true;

OutWord++;

 

for (int i = 0; i < str.size(); i++)

{

if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z') || (ch >= '' && ch <= '') || (ch >= '' && ch <= ''))

{

SetColor(0, 14);

}

else

{

if (!(str[i] == '-' && str.size() > i + 1))

SetColor(15, 0);

}

cout << str[i];

}

ColorWordIsWrite = true;

}

NowOutWord++;

}

}

 

 

if (!ColorWordIsWrite)

{

SetColor(15, 0);

cout << str;

}

else

{

ColorWordIsWrite = false;

}

 

 

SetColor(15, 0);

 

do

{

InputFile.get(ch);

 

if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch >= '' && ch <= '') || (ch >= '' && ch <= '')))

{

cout << ch;

Symbols++;

if (ch == '\n')

Symbols++;

}

else

{

if (!InputFile.eof())

InputFile.seekg(Symbols - 1);

break;

}

}

while (!InputFile.eof());

 

 

if (InputFile.eof() &&!IsFinishSearch)

{

exit = true;

}

}

while (!InputFile.eof());

 

 

cout << "\n\n";

cout << " " << SizeShortWord << " ().\n\n";

cout << " .\n";

 

IsFinishSearch = false;

 

InputFile.clear();

InputFile.seekg(0, std::ios::beg); //

 

}

while (!exit);

 

 

InputFile.close();

 

SetColor(15, 0);

cout <<"\n\n";

system("pause");

return 0;

}

 

void SetColor(int text, int background)

{

HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleTextAttribute(hStdOut, (WORD)((background << 4) | text));

}


1

 

:

 

Lorem Ipsum is simply dummy text of the printing and typesetting

industry. Lorem Ipsum has been the industry's standard dummy text

ever since the 1500s, when an unknown printer took galley of type

and scrambled it to make type specimen book. It has survived not

 

 

only five centuries, but also the leap into electronic typesetting,

remaining essentially unchanged. It was popularised in the 1960s

 

with the release of Letraset sheets containing Lorem Ipsum passages,

and more recently with desktop publishing software like Aldus

PageMaker including versions of Lorem Ipsum.

 

2 ().

 

.


<string.h>, , .

( ) get ifstream . seekg ifstream. clear.





:


: 2017-02-25; !; : 528 |


:

:

- , , .
==> ...

1595 - | 1392 -


© 2015-2024 lektsii.org - -

: 0.026 .