Вот моя прога большая правда? P.S. почему-то некоторые операторы заменились смайликами!!!
Код:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define Esc 27
#define MAX_STRING 30
#define MAX_WORD 20
int k,n,t,f,M_temp=0,run=0,SS=0,error=0,TEMP=0;
char Str[MAX_STRING][MAX_WORD+2],Sp[MAX_STRING],scan_spase=0;
void ReadData()
{
char ch,er;
int i,j=0,x,y,s,detect=0,o;
for(s=0;s<MAX_STRING;s++)
Sp[s]=0;
j=0;
printf("\n\n");
printf("******************** The program is started *********************\n\n");
printf("Please inter the sentences:\n");
while(j<MAX_STRING)
{
for(i=1;i<(MAX_WORD+3);i++)
{
if(i==(MAX_WORD+2))
{
x=wherex();
y=wherey();
printf("\n\aError 001: Length of a word exceeds norm!");
gotoxy((x-1),y);
printf(" ");
gotoxy((x-1),y);
i--;
}
if(j==MAX_STRING)
{
x=wherex();
y=wherey();
printf("\n\aError 002: Is long the sentences above than norm! Enter '!' or '?' or '.'!");
gotoxy((x-1),y);
printf(" ");
gotoxy((x-1),y);
j--;
while(er!='.' && er!='?' && er!='!')
{
er=getche();
printf("\b");
if(er=='.' || er=='?' || er=='!')
{
ch=er;
if(ch=='!')
{
printf("!");
M_temp=1;
}
if(ch=='.')
{
printf(".");
M_temp=2;
}
if(ch=='?')
{
printf("?");
M_temp=3;
}
goto M;
}
if(er=='\b')
{
y=wherey();
i=0;
j=0;
gotoxy(1,y);
printf(" ");
printf("\n ");
gotoxy(1,y);
break;
}
}
}
ch=getche();
if((ch==' ') && (run==0))
{
scan_spase=1;
SS=1;
Sp[j]--;
}
run=1;
if((ch>='A')&&(ch<='z')&&(ch!=Esc)||(ch==' ')||(ch=='!')||(ch=='.')||(ch=='?'))
{
if(ch=='!')
M_temp=1;
if(ch=='.')
M_temp=2;
if(ch=='?')
M_temp=3;
M: y=wherey();
x=wherex();
gotoxy(1,y+1);
printf(" ");
gotoxy(x,y);
if((ch!=' ') && (ch!='!') && (ch!='.') && (ch!='?'))
Str[j][i]=ch;
if(ch==' ')
{
Sp[j]++;
if((detect!=1) && (scan_spase!=1))
{
Str[j][i]=0;
i=0;
j+=1;
detect=1;
}
else
i=0;
}
else
{
detect=0;
scan_spase=0;
}
if((ch=='!')||(ch=='.')||(ch=='?'))
{
if((Str[j][1]>='A') && (Str[j][1]<='z'))
{}
else
{
TEMP=1;
}
t=j+1;
break;
}
}
else
{
if(ch==Esc)
{
y=wherey();
x=wherex();
gotoxy(x-1,y);
printf(" ");
printf("\n\n*********************The program is closed***********************");
error=1;
return;
}
if(ch=='\b')
{
for(o=1;o<=j;o++)
Sp[o]=0;
for(o=0;o<j+1;o++)
{
for(i=1;Str[j][i]!=0;i++)
Str[o][i]=0;
}
y=wherey();
i=0;
j=0;
gotoxy(1,y);
printf(" ");
gotoxy(1,y);
}
else
{
x=wherex();
y=wherey();
printf("\a\nError 003: You should enter only latin letters!");
gotoxy((x-1),y);
printf(" ");
gotoxy((x-1),y);
i--;
continue;
}
}
}
break;
}
printf("\n");
}
void main()
{
int K,N,incorrect_size,number,incorrect_number,i,j,temp=0,a=0,b=0,max,min,MAX,MIN;
char temp1[MAX_WORD+2];
clrscr();
ReadData();
Sp[t-1]++;
if(error!=1)
{
printf("\n**************The sentences is entered successfully**************");
printf("\n\nEnter whole 'K' and 'N' for replacement of words in sentences:");
}
if(error!=1)
{
while(1)
{
for(;;)
{
incorrect_number=0;
printf("\nPlease, inter K=");
fflush(stdin);
if((scanf("%d.%d",&K,&incorrect_number))==0)
{
printf("Error 001: you have intered not number!\n");
continue;
}
else
{
if((K<1)||(K>(t-TEMP)))
{
printf("Error002: 0 < K <= %d\n",(t-TEMP));
continue;
}
else
{
if(incorrect_number!=0)
{
printf("\nError003: you have intered not an integer number!\n");
continue;
}
else
break;
}
}
}
for(;;)
{
incorrect_number=0;
printf("Please, inter N=");
fflush(stdin);
if((scanf("%d.%d",&N,&incorrect_number))==0)
{
printf("Error 001: you have intered not number!\n");
continue;
}
else
{
if((N<1)||(N>t-(TEMP)))
{
printf("Error002: 0 < N <= %d\n",(t-TEMP));
continue;
}
else
{
if(incorrect_number!=0)
{
printf("\nError003: you have intered not an integer number!\n");
continue;
}
else
break;
}
}
}
if(K==N)
printf("\nThe incorrect data. Try again.");
else
break;
}
printf("\n****************The entered data are accepted********************\n\n");
printf("The resulting sentences:\n");
for(i=1;Str[K-1][i]!=0;i++)
a++;
for(i=1;Str[N-1][i]!=0;i++)
b++;
if(a>b)
{
max=a;
min=b;
MAX=K;
MIN=N;
}
else
{
max=b;
min=a;
MAX=N;
MIN=K;
}
for(i=1;i<=max;i++)
temp1[i]=Str[MAX-1][i];
for(i=1;i<=min;i++)
Str[MAX-1][i]=Str[MIN-1][i];
for(i=1;i<=max;i++)
Str[MIN-1][i]=temp1[i];
Str[MAX-1][min+1]=0;
if(SS!=1)
{
for(j=0;j<t;j++)
{
for(i=1;Str[j][i]!=0;i++)
printf("%c",Str[j][i]);
while(temp<Sp[j+1])
{
printf(" ");
temp++;
}
temp=0;
}
}
else
{
for(j=0;j<t;j++)
{
while(temp<Sp[j])
{
printf(" ");
temp++;
}
for(i=1;Str[j][i]!=0;i++)
printf("%c",Str[j][i]);
temp=0;
}
}
if(M_temp==1)
printf("!");
if(M_temp==2)
printf(".");
if(M_temp==3)
printf("?");
printf("\n\n***************The program is successfully executed**************");
printf("\n\n\aPress any key for closing the program!\n");
getche();
}
}