diff --git a/proglabs/lab9/func/.get.c.swp b/proglabs/lab9/func/.get.c.swp new file mode 100644 index 0000000..0612ead Binary files /dev/null and b/proglabs/lab9/func/.get.c.swp differ diff --git a/proglabs/lab9/func/.massive.c.swp b/proglabs/lab9/func/.massive.c.swp new file mode 100644 index 0000000..7e1664d Binary files /dev/null and b/proglabs/lab9/func/.massive.c.swp differ diff --git a/proglabs/lab9/func/func.h b/proglabs/lab9/func/func.h index 6d83f4b..23ad281 100644 --- a/proglabs/lab9/func/func.h +++ b/proglabs/lab9/func/func.h @@ -11,6 +11,7 @@ // GET int mainget(void); int numget(void); +int getsymb(int *b,wchar_t *buff); // MASSIVE void seeMassive(wchar_t (*massive)[COL]); diff --git a/proglabs/lab9/func/func.h~ b/proglabs/lab9/func/func.h~ new file mode 100644 index 0000000..da45e2e --- /dev/null +++ b/proglabs/lab9/func/func.h~ @@ -0,0 +1,31 @@ +#ifndef FUNC +#define FUNC + +#include +#include +#include +#include +#define COL 10 +#define ROW 10 + +// GET +int mainget(void); +int numget(void); +int getsymb(wchar_t *buff); + +// MASSIVE +void seeMassive(wchar_t (*massive)[COL]); +void setMassive(int x, wchar_t (*massive)[COL]); +void func(int x, wchar_t (*massive)[COL]); + +// MENU +void helpMenu(void); +void setMenu(void); +void funcMenu(void); + +// SPECIAL +void clear(void); +int flush(void); +int end(int c); + +#endif diff --git a/proglabs/lab9/func/get.c b/proglabs/lab9/func/get.c index bcc9fb5..f2949c4 100644 --- a/proglabs/lab9/func/get.c +++ b/proglabs/lab9/func/get.c @@ -1,17 +1,18 @@ #include "func.h" int mainget(void){ - int t,x,y=0,num=0; + int t=0,x,y=0,num=0; unsigned long input = 0; while( ((x=getchar())>=32 && t<100) && ((x>='a' && x<='z') || (x>='0' && x<= '9') || (x>='A' && x<='Z'))){ + // printf("%d %lu ",x,input); if(x>='a' && x<='z') {x -=('a'-'A');t--;} if(x>='A' && x<='Z') {input = (input*100)+(x);t--;} + // printf("%d %lu\n",x,input); if(input>1000000000000000000){printf("input err\n\n");flush();input=0;t--;} - if(x>='0' && x<='9'&&num<147483647){num = (num*10)+(x-'0');t--;} else if(num>147483647){printf("num is too big!\n\n");num = 0;t--;} if(t<0)t=0; @@ -25,7 +26,6 @@ int mainget(void){ int help = 72697680; int show = 83727987; - int see = 836969; int set = 836984; @@ -51,8 +51,32 @@ int mainget(void){ if(y==3&&(num>=10&&num<=21)) y = 300+num; y=(input == show)?4:y; - y=(input == see)?4:y; + y=(input == 'C')?4:y; return y; } + +int getsymb(int *b,wchar_t *buff){ + int t; + *b=0; + wchar_t x; + while((x=getchar())!=end(x)&&x!='\n'&&x!=' '&&*b<5){ + if(x=='/n')x=' '; + *(buff+*b) = x; + *b++; + } + //if(end(x)){flush();return -1;} + + t=0; + if(*buff=='-'){ + for(int i = 1; i<4;i++){ + if(*(buff+i)>='0'&&*(buff+i)<='9')t++; + } + if(*(buff+4)=='-') + if(t==4)return 1; + } + t=0; + getchar(); + return 0; +} diff --git a/proglabs/lab9/func/get.c~ b/proglabs/lab9/func/get.c~ new file mode 100644 index 0000000..346ba74 --- /dev/null +++ b/proglabs/lab9/func/get.c~ @@ -0,0 +1,83 @@ +#include "func.h" + +int mainget(void){ + int t=0,x,y=0,num=0; + unsigned long input = 0; + while( + ((x=getchar())>=32 && t<100) + && ((x>='a' && x<='z') + || (x>='0' && x<= '9') + || (x>='A' && x<='Z'))){ + // printf("%d %lu ",x,input); + if(x>='a' && x<='z') {x -=('a'-'A');t--;} + if(x>='A' && x<='Z') {input = (input*100)+(x);t--;} + // printf("%d %lu\n",x,input); + if(input>1000000000000000000){printf("input err\n\n");flush();input=0;t--;} + if(x>='0' && x<='9'&&num<147483647){num = (num*10)+(x-'0');t--;} + else if(num>147483647){printf("num is too big!\n\n");num = 0;t--;} + if(t<0)t=0; + t++; + if(end(x))return -1; + } + + if(end(x))return -1; + + int exit = 69887384; + int help = 72697680; + + int show = 83727987; + + int set = 836984; + + int func = 70857867; + + + y=(input == exit)?-1:y; + y=(input == 'Q')?-1:y; + + y=(input == help)?1:y; + y=(input == 'H')?1:y; + + + y=(input == set)?2:y; + y=(input == 'S')?2:y; + if(y==2&&(num>=1&&num<=9)) y = 20+num; + if(y==2&&(num==10)) y = 200+num; + + + y=(input == func)?3:y; + y=(input == 'F')?3:y; + if(y==3&&(num>=1&&num<=9)) y = 30+num; + if(y==3&&(num>=10&&num<=21)) y = 300+num; + + y=(input == show)?4:y; + y=(input == 'C')?4:y; + + + return y; +} + +int getsymb(int *b,wchar_t *buff){ + int t; + *b=0; + wchar_t x; + while((x=getchar())!=end(x)&&x!='\n'&&x!=' '&&*b<5){ + if(x=='/n')x=' '; + *(buff+*b) = x; + *b++; + } + //if(end(x)){flush();return -1;} + + t=0; + if(*buff=='-'){ + for(int i = 1; i<4;i++){ + if(*(buff+i)>='0'&&*(buff+i)<='9')t++; + } + if(*(buff+4)=='-') + if(t==4)return 1; + } + t=0; + printf("\nx "); + getchar(); + return 0; +} diff --git a/proglabs/lab9/func/massive.c b/proglabs/lab9/func/massive.c index 1c5b307..268ae17 100644 --- a/proglabs/lab9/func/massive.c +++ b/proglabs/lab9/func/massive.c @@ -13,17 +13,67 @@ void seeMassive(wchar_t (*massive)[COL]){ } putchar('\n');putchar('\n'); } - - printf("\n\nInput: "); return; } void setMassive(int x, wchar_t (*massive)[COL]){ + int b,c,o,e,cell=0; + wchar_t buff[5]; + switch(x){ + case 21: + for(int col = 0;colROW*COL-1) + printf("Error cell cannot be bigger %d",ROW*COL-1); + else while(cell>0){ + col = row = 0; + if(colROW*COL-1) + printf("Error cell cannot be bigger %d",ROW*COL-1); + else while(cell>0){ + col = row = 0; + if(col=21 && x<=29) || x==210){ - if(x==2){setMenu();flush();} + if(x==2){setMenu();printf("Input: X");} else setMassive(x,massive); } else if(x==3 || (x>=31 && x<=39) || (x>=310 && x<=320)){ - if(x==3) funcMenu(); + if(x==3) {funcMenu();printf("Input: ");} else func(x,massive); } else if(x==4){ - seeMassive(massive); + seeMassive(massive);printf("Input: "); } - else {printf("Input Error \"%d\" is undefind command.\nInput: ",x);} + else {printf("Input Error \"%d\" is undefind command.\n",x); + printf("\tTo get command list input: help\nInput: ");} } return 0; } diff --git a/proglabs/lab9/main.c~ b/proglabs/lab9/main.c~ new file mode 100644 index 0000000..db3b2f6 --- /dev/null +++ b/proglabs/lab9/main.c~ @@ -0,0 +1,39 @@ +#include "./func/func.h" +int chooseMassiveInput(); + +int main(){ + int x; + + setlocale(LC_ALL, "en_US.UTF-8"); + + wchar_t massive[ROW][COL]; + for(int i = 0;i=21 && x<=29) || x==210){ + if(x==2){setMenu();printf("Input: X");} + else setMassive(x,massive); + } + + else if(x==3 || (x>=31 && x<=39) || (x>=310 && x<=320)){ + if(x==3) {funcMenu();printf("Input: ");} + else func(x,massive); + } + + else if(x==4){ + seeMassive(massive); + } + + else {printf("Input Error \"%d\" is undefind command.\n",x); + printf("\tTo get command list input: help\nInput: ");} + } + return 0; +} diff --git a/proglabs/lab9/prog b/proglabs/lab9/prog index 5b64152..c1b2a84 100755 Binary files a/proglabs/lab9/prog and b/proglabs/lab9/prog differ