include stdafx include stdlib include windows include string include l

  1
  2
  3
  4
  5
  6
  7
  8
  9
 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
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
#include "stdafx.h"
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <locale.h>
#define N 500
int main(int argc, char *argv[])
{
setlocale(LC_ALL,"Russian");
FILE *file, *file2 ;
long int end; /* ïðèçíàê êîíöà ôàéëà */
int i=0; /* èíäåêñ ñòðîêè */
int COLVOslov=0, MAXslov=0; /* COLVOslov-ñ÷åòêèê êîë-âà ñëîâ â ñòðîêå, MAXslov-ìàêñèìàëüíîå êîë-âî ñëîâ â ñòðîêå*/
char si; /* ïîñèìâîëüíîå ñ÷èòûâàíèå èç ôàéëà */
char *pi; /* óêàçàòåëü äëÿ strtok */
char Vstr[N]="\0", MAXstr[N]="\0",strWithMaxSlov[N]="\0"; /* âðåìåííàÿ ñòðîêà, ìàêñèìàëüàÿ ñòðîêà, ñòðîêà ñ ìàêñèìàëüíûì êîë-âîì ñëîâ*/
fpos_t posN,posNMAX;
/* ðîçîâàÿ ìèëîòà */
HANDLE consoleOutput;
consoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(consoleOutput, 1 | FOREGROUND_RED | FOREGROUND_INTENSITY);
file = fopen("cisla.txt", "a+");
fseek(file , 0, SEEK_END );
end = ftell(file);
fseek(file , 0, SEEK_SET );
if(file != NULL)
{
fgetpos(file, &posN);
while( (si=getc(file))!=EOF )
{
if (si!='.')
{
Vstr[i]=si;
i++;
}
else
//{
Vstr[i]='\0';
/*
if(strlen(Vstr)>strlen(MAXstr))
strcpy(MAXstr,Vstr);
pi=strtok(Vstr," ,/|\()");
while(pi)
{
COLVOslov++;
pi=strtok(NULL," ,/|\()");
}
if(COLVOslov>MAXslov)
{
MAXslov=COLVOslov;
posNMAX=posN;
}
fgetpos(file, &posN);
COLVOslov=0;
i=0;
*/
//} /* çàêðûâàåì else */
}
}
i=0;
fsetpos(file,&posNMAX);
while((si=getc(file))!='.')
{
strWithMaxSlov[i]=si;
i++;
}
file2 = fopen("sliv.txt", "w+");
if(file2 != NULL)
{
fprintf(file2, "ñàìàÿ äëèííàÿ ôðàçà: \n %s\n", MAXstr);
fprintf(file2, "ôðàçà ñ íàèáîëüøèì êîëè÷åñòâîì ñëîâ: \n %s\n",strWithMaxSlov);
}
/*fscanf(file,"%s", proverkaslova);
if( strlen(proverkaslova)>strlen(maxslovo))
strcpy(maxslovo,proverkaslova); */
/* fgets(chto, 30, file);
printf("ok\n");
*/
printf( " âîçðàäóéñÿ! <3 ");
fclose(file);
fclose(file2);
system("PAUSE");
return 0;
}