В общем у меня вот что есть. Делаю пока сложение. Но как-то плохо получается..... Помогите, плиз! Код в прикреплённом файле. Консоль, для DOC


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<bios.h>
int proverka(char *a)
{int i,s=0;
if(a[0]=='(') s++;
if((a[0]<'0'||a[0]>'9')&&(a[0]!='+'&&a[0]!='-'&&a[0]!='('))
{printf("error33");
free(a);
return 1;
}
for(i=1;a[i]!='=';i++)
{if(a[i]=='(') s++;
else if(a[i]==')'){ s--;if(s<0){ printf("error3");free(a);return 1; }}
else
{if(a[i]=='+'||a[i]=='-'||a[i]=='*'||a[i]=='/')
{if((a[i-1]<'0'||a[i-1]>'9')&&a[i-1]!=')')
{printf("error1");
free(a);
return 1;
}
}
else if(a[i]<'0'||a[i]>'9')
{printf("error3");
free(a);
return 1;
}
}
}
if(s!=0)
{printf("error3");
free(a);
return 1;
}

}


char* slojenie(int i1, int i2, char *a)
{int i,w=0,j;
char *sl;

if(i1>=i2-i1-2)
{sl=(char *)realloc(sl,i1+1);
for(i=i1;i>-1;i--)
{//printf("<%c> ",a[i]+a[i2-i1+i]+w-'0');
//getch();
(a[i]+a[i2-i1+i]-'0'>'9')?(sl[i]=a[i]+a[i2-i1+i]+w-10-'0',w=1):(sl[i]=a[i]+a[i2-i1+i]+w-'0',w=0);
}
}
for(i=0;i<i1+1;i++)
printf("%c",sl[i]);
return sl;
}
char* war(char *a)
{int i1,i2,j,q=0;
char *result;
for(j=0;a[j]!='=';j++)
{if(a[j]=='+')
{i1=j-1;
}
}
i2=j-1;
result=slojenie(i1,i2,a);
free(result);
}

char *buff;


//function risovaniya ramki
void frame(int x, int y, int dl,int vis)


{int i;
for(i=x+1;i<x+dl-1;i++)
{gotoxy(i,y); printf("%c",205);
gotoxy(i,y+vis);printf("%c",205);
}
gotoxy(x,y); printf("%c",201);
gotoxy(x+dl-1,y); printf("%c",187);
gotoxy(x,y+vis); printf("%c",200);
gotoxy(x+dl-1,y+vis); printf("%c",188);
for(i=1;i<vis;i++)
{gotoxy(x,y+i); printf("%c",186);
gotoxy(x+dl-1,y+i); printf("%c",186);
}

} //function risovaniya knopki
void key(int x,int y,char symb)


{gotoxy(x,y); printf("%c",201);
gotoxy(x+1,y); printf("%c",205);
gotoxy(x+2,y); printf("%c",187);
gotoxy(x,y+1); printf("%c",186);
gotoxy(x+1,y+1); printf("%c",symb);
gotoxy(x+2,y+1); printf("%c",186);
gotoxy(x,y+2); printf("%c",200);
gotoxy(x+1,y+2); printf("%c",205);
gotoxy(x+2,y+2); printf("%c",188);
}




// function risovaniya klaviaturi
void klav(int x,int y)


{int i,j;
for(i=1;i<4;i++)
{for(j=1;j<4;j++)
{key(j*3-2+x,i*3-2+y,'0'+3*i+j-3);
}
}
key(x+1,y+10,'x');key(x+4,y+10,'0');key(x+7,y+10,'/');
key(x+10,y+4,'+');key(x+10,y+7,'-');key(x+23,y+17,'Q');key(x+13,y+4,'=');
frame(x+1,y+17,9,2);gotoxy(x+2,y+18); printf("Console");frame(x+10,y+17,5,2);
gotoxy(x+11,y+18);printf("DEL");
frame(x+15,y+17,8,2); gotoxy(x+16,y+18); printf("DelALL");

}

void refresh()
{ textbackground(BLUE);
clrscr();
frame(1,1,80,2);
klav(1,4);
gotoxy(1,1);
}
int calc()



{ refresh();
int s4et=-1,i,j;

_setcursortype(1) ;
int a=0,x=1,y=1,x1=-1,y1=-1;


while(1)
{a=bioskey(0); //
switch(a) //
{case 18432: //
if(y>1){gotoxy(x,y=y-1);} //
break; //
case 20480: // dvigenie kursora
if(y<50){gotoxy(x,y=y+1);} //
break; //
case 19712: //
if(x<80){gotoxy(x=x+1,y);} //
break; //
case 19200: //
if(x>1){gotoxy(x=x-1,y);} //
break;
case 7181: // pri najatii klavishi <enter>

if(y==22)
{ if(x>11&&x<15)
{if(s4et>-1)
{ s4et--;
gotoxy(s4et+3,2);
printf(" ");
free(buff+s4et+2);
}
}

else if(x>16&&x<23)
{
gotoxy(2,2);
for(i=0;i<s4et+1;i++) printf(" ");
free(buff);
s4et=-1;
}

else if(x>1&&x<9)
{gotoxy(2,2);
for(i=0;i<s4et;i++) printf(" ");
s4et=-1;
//clrscr();
free(buff);
gotoxy(1,30);
while(buff[s4et]!='=')
{s4et++;
buff=(char *)realloc(buff,s4et+1);
buff[s4et]=getch();
if(buff[s4et]==8&&s4et>1)
{ realloc(buff,(s4et=s4et-2)+1);
if(wherex()==1)
{gotoxy(80,wherey()-1);
printf(" ");
gotoxy(80,wherey()-1);
}
else
{ printf("%c %c",8,8);}
}
else
{printf("%c",buff[s4et]); }
}
printf("\n");
for(i=0;i<=s4et;i++)
{printf("%c",buff[i]);
}
proverka(buff);
war(buff);
}
else if(x==25)
{free(buff);
return 0;
}

}



else if(s4et<77)

{ if(y==6)
{
if(x==3) // esli kursor nahoditsya na klavishi "1"
{
gotoxy(3+s4et,2);
s4et++;
printf("1");
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}


buff[s4et]='1';

}

else if(x==6)
{
gotoxy(s4et+3,2);
printf("2");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='2';
}

else if(x==9)
{
gotoxy(s4et+3,2);
printf("3");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='3';
}





}
else if(y==9)
{
if(x==3)
{gotoxy(s4et+3,2);
printf("4");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='4';
}
else if(x==6)
{gotoxy(s4et+3,2);
printf("5");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='5';
}
else if(x==9)
{gotoxy(s4et+3,2);
printf("6");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='6';
}
else if(x==12)
{gotoxy(s4et+3,2);
printf("+");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='+';
x1=s4et-1;
}
else if(x==15)
{gotoxy(20,20);
for(i=0;i<s4et+1;i++) printf("%c",buff[i]);
//y1=s4et;
//clojenie(x1,y1);
//x1=0;
//y1=0;
getch();
}
}
else if(y==12)
{if(x==3)
{gotoxy(s4et+3,2);
printf("7");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='7';
}
else if(x==6)
{gotoxy(s4et+3,2);
printf("8");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='8';
}
else if(x==9)
{gotoxy(s4et+3,2);
printf("9");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='9';
}
else if(x==12)
{gotoxy(s4et+3,2);
printf("-");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='-';
}

}
else if(y==15)
{if(x==3)
{gotoxy(s4et+3,2);
printf("x");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='x';
}
else if(x==6)
{gotoxy(s4et+3,2);
printf("0");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='0';
}
else if(x==9)
{gotoxy(s4et+3,2);
printf("/");
s4et++;
buff=(char *)realloc(buff,s4et+1);
if(buff==NULL)
{printf("out of memory");
getch();
free(buff);
return 0;
}
buff[s4et]='/';
}
}
}
}
}


//gotoxy(x,y);
//free(buff);
//break;
}

main()
{calc();

}