include stdio include stdlib include windows include string include lo

  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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <locale.h>
#define N 100000
int main(int argc, char *argv[])
{
FILE *file, *file2 ;
long int end; /* ïðèçíàê êîíöà ôàéëà */
int i=0; /* èíäåêñ ñòðîêè */
int COLVOslov=0, MAXslov=0, scethic=0, MAXstrok=0, flag=0; /* COLVOslov-ñ÷åòêèê êîë-âà ñëîâ â ñòðîêå, MAXslov-ìàêñèìàëüíîå êîë-âî ñëîâ â ñòðîêå*/
char si; /* ïîñèìâîëüíîå ñ÷èòûâàíèå èç ôàéëà */
fpos_t posN,posNMAXCOLslov, posNMAXdlin;
/* ïåðåìåííûå äëÿ îòêðûòèÿ ôàéëà ÷åðåç ïàðàìåòðû ô-è main() */
int a=1; /* èíäåêñ äëÿ àðãóìåíòà argv ô-è main() */
char namefH[1000]={},namefZ[1000]={}; /* namefH-ôàéë ÷òåíèÿ, namefZ-ôàéë çàïèñè */
/* ðîçîâàÿ ìèëîòà */
HANDLE consoleOutput;
consoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(consoleOutput, 1 | FOREGROUND_RED | FOREGROUND_INTENSITY);
/* ïðîâåðêà êîë-âà ïåðåäàííûõ ïàðàìåòðîâ */
if(argc==1)
{
printf(" ‚¢¥¤¨â¥ ¨¬ï ä ©«  ¤«ï ®¡à ¡®âª¨:\n");
scanf("%s", namefH);
printf(" ‚¢¥¤¨â¥ ¨¬ï ¢ë室­®£® ä ©«:\n");
scanf("%s", namefZ);
}
if(argc==2)
{
strcpy(namefH,argv[1]);
printf(" ‚¢¥¤¨â¥ ¨¬ï ¢ë室­®£® ä ©«: \n");
scanf("%s", namefZ);
}
if(argc==3)
{
strcpy(namefH,argv[1]);
strcpy(namefZ,argv[2]);
}
/* ïðîâåðêà îòêðûòèÿ ôàéëà */
if((file=fopen(namefH,"r+"))== NULL)
{
printf(" ­¥ 㤠«®áì ®âªàëâì: %s\n", namefH);
system("PAUSE");
return 1;
}
if((file2=fopen(namefZ,"w+")) == NULL)
{
printf(" ­¥ 㤠«®áì ®âªàëâì: %s\n", namefZ);
system("PAUSE");
return 1;
}
fseek(file , 0, SEEK_END );
end = ftell(file);
fseek(file , 0, SEEK_SET );
fgetpos(file, &posN);
while( ftell(file)!=end )
{
si=fgetc(file);
if((si!='.') && (ftell(file)!=end))
{
scethic++;
if ( ( si=='\n' || si==' ' || si==',' || si=='(' || si==')' || si=='\' || si=='/' || si=='?' ) && flaq==0 ) )
{
COLVOslov++;
flag++;
}
else
flag=0;
}
else
{
if(ftell(file)==end)
scethic++;
if(scethic>MAXstrok)
{
MAXstrok=scethic;
posNMAXdlin=posN;
}
if(COLVOslov>MAXslov)
{
MAXslov=COLVOslov;
posNMAXCOLslov=posN;
}
fgetpos(file, &posN);
}
}
/* çàïèñü â ôàéë */
fprintf(file2, "\n Càìàÿ äëèííàÿ ñòðîêà: \n ", );
fsetpos(file,&posNMAX);
while((si=getc(file))!='.' )
{
if(si!='\n')
printf(file2,"%c",si);
if(ftell(file)==end)
break;
}
fprintf(file2, "\n Ìàêñèìàëüíîå êîëè÷åñòâî ñëîâ: \n", );
fsetpos(file,&posNMAXCOLslov);
while((si=getc(file))!='.' )
{
if(si!='\n')
printf(file2,"%c",si);
if(ftell(file)==end)
break;
}
fclose(file);
fclose(file2);
system("PAUSE");
return 0;
}