diff --git a/proglabs/lab9/compile.sh b/proglabs/lab9/compile.sh new file mode 100755 index 0000000..e70a865 --- /dev/null +++ b/proglabs/lab9/compile.sh @@ -0,0 +1 @@ +gcc -std=c99 -Wall main.c ./func/get.c ./func/massive.c ./func/menu.c ./func/special.c -o prog diff --git a/proglabs/lab9/func/func.h b/proglabs/lab9/func/func.h new file mode 100644 index 0000000..6d83f4b --- /dev/null +++ b/proglabs/lab9/func/func.h @@ -0,0 +1,30 @@ +#ifndef FUNC +#define FUNC + +#include +#include +#include +#include +#define COL 10 +#define ROW 10 + +// GET +int mainget(void); +int numget(void); + +// 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 new file mode 100644 index 0000000..bcc9fb5 --- /dev/null +++ b/proglabs/lab9/func/get.c @@ -0,0 +1,58 @@ +#include "func.h" + +int mainget(void){ + int t,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'))){ + if(x>='a' && x<='z') {x -=('a'-'A');t--;} + if(x>='A' && x<='Z') {input = (input*100)+(x);t--;} + 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 see = 836969; + + 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 == see)?4:y; + + + return y; +} diff --git a/proglabs/lab9/func/massive.c b/proglabs/lab9/func/massive.c new file mode 100644 index 0000000..1c5b307 --- /dev/null +++ b/proglabs/lab9/func/massive.c @@ -0,0 +1,29 @@ +#include "func.h" + +void seeMassive(wchar_t (*massive)[COL]){ + printf("\t\t\tMassive\n\n[ ] "); + for(int i = 0;i=21 && x<=29) || x==210){ + if(x==2){setMenu();flush();} + else setMassive(x,massive); + } + + else if(x==3 || (x>=31 && x<=39) || (x>=310 && x<=320)){ + if(x==3) funcMenu(); + else func(x,massive); + } + + else if(x==4){ + seeMassive(massive); + } + + else {printf("Input Error \"%d\" is undefind command.\nInput: ",x);} + } + return 0; +} diff --git a/proglabs/lab9/prog b/proglabs/lab9/prog new file mode 100755 index 0000000..5b64152 Binary files /dev/null and b/proglabs/lab9/prog differ diff --git a/proglabs/lab9/test.txt b/proglabs/lab9/test.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/ascii.c b/test/ascii.c new file mode 100644 index 0000000..4a0ce7e --- /dev/null +++ b/test/ascii.c @@ -0,0 +1,19 @@ +#include + +int main(void){ + int x; + unsigned long input = 0; + while((x=getchar())!='\n' + && ((x>='a' && x<='z') + || (x>='A' && x<='Z'))){ + if (x<=32 && x!='\n' && x!=' ' && x!='\t') return -1; + + printf("%d\t",x); + if(x>='a' && x<='z') x -= ('a'-'A'); + printf("%d\t",x); + if(x>='A' && x<='Z') input = (input*100)+(x); + + printf("%d %lu\n",x,input); + } + return 0; +} diff --git a/test/max.c b/test/max.c new file mode 100644 index 0000000..5feea62 --- /dev/null +++ b/test/max.c @@ -0,0 +1,28 @@ +#include +#include +#include + +int main(void) { + /* Integer types */ + printf("Signed char : %d … %d\n", SCHAR_MIN, SCHAR_MAX); + printf("Unsigned char : 0 … %u\n", UCHAR_MAX); + printf("Signed short : %d … %d\n", SHRT_MIN, SHRT_MAX); + printf("Unsigned short: 0 … %u\n", USHRT_MAX); + printf("Signed int : %d … %d\n", INT_MIN, INT_MAX); + printf("Unsigned int : 0 … %u\n", UINT_MAX); + printf("Signed long : %ld … %ld\n", LONG_MIN, LONG_MAX); + printf("Unsigned long : 0 … %lu\n", ULONG_MAX); + printf("Signed long long : %lld … %lld\n", LLONG_MIN, LLONG_MAX); + printf("Unsigned long long: 0 … %llu\n", ULLONG_MAX); + + /* Floating‑point types */ + printf("\nFloat : %e … %e (precision: %d digits)\n", + -FLT_MAX, FLT_MAX, FLT_DIG); + printf("Double : %e … %e (precision: %d digits)\n", + -DBL_MAX, DBL_MAX, DBL_DIG); + printf("Long double : %Le … %Le (precision: %d digits)\n", + -LDBL_MAX, LDBL_MAX, LDBL_DIG); + + return 0; +} + diff --git a/test/tmp.out b/test/tmp.out new file mode 100755 index 0000000..88d1479 Binary files /dev/null and b/test/tmp.out differ