diff --git a/infolabs/assembly/code.c b/infolabs/assembly/code.c new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/infolabs/assembly/code.c @@ -0,0 +1 @@ +a diff --git a/infolabs/procmemorylearning/Отчёт по информатике на тему Исследование иерархии памяти, работы процессора в ЭВМ на языке Си.pdf b/infolabs/procmemorylearning/Отчёт_по_информатике_на_тему_Иерархии_памяти,_работы_процессора.pdf similarity index 70% rename from infolabs/procmemorylearning/Отчёт по информатике на тему Исследование иерархии памяти, работы процессора в ЭВМ на языке Си.pdf rename to infolabs/procmemorylearning/Отчёт_по_информатике_на_тему_Иерархии_памяти,_работы_процессора.pdf index 31d6871..c71eb2c 100644 Binary files a/infolabs/procmemorylearning/Отчёт по информатике на тему Исследование иерархии памяти, работы процессора в ЭВМ на языке Си.pdf and b/infolabs/procmemorylearning/Отчёт_по_информатике_на_тему_Иерархии_памяти,_работы_процессора.pdf differ diff --git a/proglabs/lab8/code.c b/proglabs/lab8/code.c index de7f009..584520b 100644 --- a/proglabs/lab8/code.c +++ b/proglabs/lab8/code.c @@ -1,12 +1,4 @@ -#include -#define MAXMASSIVESIZE 10000 - - -void setmass(int *massSize); -int fillmass(int massSize, int *massive); -void viewmass(int massSize, int *massive); -void selfunc(int massive[]); -int flush(void); +#include "./func/func.h" int main() { int enter, @@ -21,7 +13,8 @@ int main() { printf("\tMassive manipulation\n"); printf("a. SetMassiveSize\n"); printf("b. FillMassive\n"); - printf("c. ViewMassive\n\n"); + printf("c. ViewMassive\n"); + printf("d. SelectFunc\n\n"); printf("\tExit - g\n\n\n"); enter = getchar(); if(flush())return 1; @@ -42,7 +35,7 @@ int main() { break; case'd': - if(massCreated){selfunc(massive);flush;} + if(massCreated){selfunc(massSize,massive);flush();} else printf("\n\tFill Massive first.\n\n"); break; @@ -54,106 +47,3 @@ int main() { }while(q); return 0; } - - -void setmass(int *massSize){ - printf("\t\tSetMassiveSize\n"); - printf("Set Massive Size - input integer\n"); - printf("Exit from this menu - input 0\n\n\n"); - printf("Input: "); - int n; - while(scanf(" %d",&n)!=1||n>MAXMASSIVESIZE){ - if(flush())return; - flush(); - if(n>10000)printf("Input cannot be >%d",MAXMASSIVESIZE); - printf("Input Err\nInput: "); - } - - flush(); - - if(n==0) - return; - else - *massSize = n; - return; -} - -int fillmass(int size, int *massive){ - printf("\t\tFill Massive\n"); - printf("You can devide elements with space or enter.\n"); - printf("You also can decide to from which element start with e.\n"); - printf("To exit input g.\n\n\n"); - printf("Input: "); - - - int x, i, e1,e = 0, p=-1, minus = 0; - - for(i = 0;i < size;i++){ - e1 = e = massive[i] = 0; - while(((x = getchar()) != '\n' && x !=' ' - && x != EOF && x != 4) - && ((x>='0' && x<='9') - || x == 'e' || (x == '-' && e==0 && massive[i]==0))) - { - if (x == 'e')e1=1; - else if (x == '-')minus=1; - - else if (e1) e = (e*10)+(x-'0'); - else massive[i] = (massive[i]*10) + (x-'0'); - } - - if(x == EOF || x == 3){return 0;} - if(e1&&minus)minus=0; - if(minus && (x == '\n' || x == ' ')){minus = 0; massive[i]*=-1;} - if(e>size) {printf("e is out of range.\n");i=p;} - else if(e1) {i = e - 1;putchar('\n');} - if(x == 'g'){return 1;} - if((x<='0' && x>='9')||x==' '||x=='\n'||x>=32); - else {while((x=getchar())!='\n'&&x!=' '&&x!=EOF&&x!=4);i--;} - if(p!=i&&e1!=1) - printf("Massive - [%d]\t%d\n",i,massive[i]); - p=i; - } - return 1; -} - - -void viewmass(int size, int *massive){ - printf("\t\tView Massive\n"); - for(int i = 0; i < size; i++){ - printf(" | [%6d]\t%p\t%d\n",i,&massive[i],massive[i]); - } -} - - -void selfunc(int *massive){ - printf("\tFunctions\t(my - 7|16|24)\n"); - printf("1. \t2. \t3. \n"); - printf("4. \t5. \t6. \n"); - printf("7. \t8. \t9. \n"); - printf("10. \t11. \t12. \n"); - printf("13. \t14. \t15. \n"); - printf("16. \t17. \t18. \n"); - printf("19. \t20. \t21. \n"); - printf("22. \t23. \t24. \n"); - printf("25. \t26. \t27. \n"); - printf("28. \t29. \t30. \n\n"); - printf("\tExit - 0\n"); - - int n; - while(scanf(" %d",&n)!=1){ - if(flush())return; - printf("Input Err\nInput: ");} - flush(); - return; - switch(n){ - - } -} - -int flush(void){ - int x; - while((x = getchar())!='\n' && x!=4 && x!=1) - if(x==EOF)return 1; - return 0; -} \ No newline at end of file diff --git a/proglabs/lab8/func/find.c b/proglabs/lab8/func/find.c new file mode 100644 index 0000000..233635c --- /dev/null +++ b/proglabs/lab8/func/find.c @@ -0,0 +1,154 @@ +#include "func.h" + +void find(int type, int size, int *massive){ + +int x,k,m,sum; +switch(type){ + + case 6: + case 8: + for (int i = size - 1; i>=0;i--) + if(massive[i]>0){ + printf("last positive int: "); + printf("[%3d]\t{%p}\t%d\n",i,&massive[i],massive[i]); + break; + } + printf("positive int is not found.\n"); + break; + + + case 7: + case 9: + for (int i = size; i>=0;i--) + if(massive[i]<0){ + printf("last negative int: "); + printf("[%3d]{%p}\t%d\n",i,&massive[i],massive[i]); + break; + } + printf("negative int is not found.\n"); + break; + + + case 14: + x=k=0; + printf("find all modules of k\nInput: "); + while(scanf(" %d",&k)!=1||k>size-1){ + if(k>size-1)printf("k shood be lower than %d",size); + if(flush())return; + } + if(flush())return; + for(int i = 0; imassive[i]){ + if(type != 21) + printf("[%3d]{%p}\t%d\n",i,&massive[i],massive[i]); + x++; + sum+=massive[i]; + } + } + if(type == 21)printf("summ - %d\n",sum); + break; + + case 25: + case 27: + case 29: + sum=0; + printf("find all int higher lower mean\nInput: "); + for(int i = 0; imassive[i]){ + if(type != 21) + printf("[%3d]{%p}\t%d\n",i,&massive[i],massive[i]); + x++; + sum+=massive[i]; + } + } + if(type == 29)printf("summ - %d\n",sum); + break; + + case 26: + case 28: + case 30: + sum=0; + printf("find all int higher lower mean\nInput: "); + for(int i = 0; i +#define MAXMASSIVESIZE 10000 + + +void setmass(int *massSize); +int fillmass(int massSize, int *massive); +void viewmass(int massSize, int *massive); +void selfunc(int size, int *massive); +int flush(void); + +void range(int type,int size, int *massive); +void find(int type,int size, int *massive); + + + +#endif diff --git a/proglabs/lab8/func/primfunc.c b/proglabs/lab8/func/primfunc.c new file mode 100644 index 0000000..8cce054 --- /dev/null +++ b/proglabs/lab8/func/primfunc.c @@ -0,0 +1,147 @@ +#include "func.h" + +void setmass(int *massSize){ + printf("\t\tSetMassiveSize\n"); + printf("Set Massive Size - input integer\n"); + printf("Exit from this menu - input 0\n\n\n"); + printf("Input: "); + int n; + while(scanf(" %d",&n)!=1||n>MAXMASSIVESIZE){ + if(flush())return; + flush(); + if(n>10000)printf("Input cannot be >%d",MAXMASSIVESIZE); + printf("Input Err\nInput: "); + } + + flush(); + + if(n==0) + return; + else + *massSize = n; + return; +} + +int fillmass(int size, int *massive){ + printf("\t\tFill Massive\n"); + printf("You can devide elements with space or enter.\n"); + printf("You also can decide to from which element start with e.\n"); + printf("To exit input g.\n\n\n"); + printf("Input: "); + + + int x, i, e1,e = 0, p=-1, minus = 0; + + for(i = 0;i < size;i++){ + e1 = e = massive[i] = 0; + while(((x = getchar()) != '\n' && x !=' ' + && x != EOF && x != 4) + && ((x>='0' && x<='9') + || x == 'e' || (x == '-' && e==0 && massive[i]==0))) + { + if (x == 'e')e1=1; + else if (x == '-')minus=1; + + else if (e1) e = (e*10)+(x-'0'); + else massive[i] = (massive[i]*10) + (x-'0'); + } + + if(x == EOF || x == 3){return 0;} + if(e1&&minus)minus=0; + if(minus && (x == '\n' || x == ' ')){minus = 0; massive[i]*=-1;} + if(e>size) {printf("e is out of range.\n");i=p;} + else if(e1) {i = e - 1;putchar('\n');} + if(x == 'g'){return 1;} + if((x<='0' && x>='9')||x==' '||x=='\n'||x<=32); + else { + while((x=getchar())!='\n'&&x!=' '&&x!=EOF&&x!=4); + i--; + printf("ErrInput\n");} + if(p!=i&&e1!=1) + printf("Massive - [%d]\t%d\n",i,massive[i]); + p=i; + } + return 1; +} + + +void viewmass(int size, int *massive){ + printf("\t\tView Massive\n"); + for(int i = 0; i < size; i++){ + printf(" | [%6d]\t%p\t%d\n",i,&massive[i],massive[i]); + } +} + + +void selfunc(int size, int *massive){ + printf("\t\tFunctions\t(my - 7|16|24)\n"); + + printf("\tRange Operations\n"); + printf("2. Find Max Range\n"); + printf("3. Find Min Range\n"); + printf("10. Sum Range\n"); + printf("11. Average Range\n"); + printf("18. Diff Min Max Range\n\n"); + + printf("\tValue Search\n"); + printf("6. Find Last Positive\n"); + printf("7. Find Last Negative\n\n"); + + printf("\tIndex Search\n"); + printf("8. Find Last Positive Index\n"); + printf("9. Find Last Negative Index\n"); + printf("13. Find Indices Between\n"); + printf("17. Find Indices Value Range\n\n"); + + printf("\tValue Filtering\n"); + printf("4. Find Indices Above\n"); + printf("5. Find Indices Below\n"); + printf("19. Count Below Value\n"); + printf("20. Count Above Value\n"); + printf("21. Sum Below Value\n"); + printf("22. Sum Above Value\n"); + printf("23. Find Indices Below Value\n"); + printf("24. Find Indices Above Value\n\n"); + + printf("\tAverage Comparisons\n"); + printf("25. Count Above Average\n"); + printf("26. Count Below Average\n"); + printf("27. Find Indices Below Average\n"); + printf("28. Find Indices Above Average\n"); + printf("29. Sum Below Average\n"); + printf("30. Sum Above Average\n\n"); + + printf("\tSpecial Conditions\n"); + printf("1. Find Min Max\n"); + printf("12. Average Range\n"); + printf("14. Count Multiples\n"); + printf("15. Count Between Equals\n"); + printf("16. Sum Value Range\n\n"); + + printf("\tExit - 0\n"); + + int n; + while(scanf(" %d",&n)!=0){ + if(flush())return; + if (n == 0) return; + if (n == 1 || n == 2 || n == 3 || n == 4 || n == 5 || + n == 10 || n == 11 || n == 12 || n == 13 || + n == 16 || n == 17 || n == 18) { + range(n, size, massive); + }else if ((n >= 6 && n <= 9) || n == 14 || n == 15 || + (n >= 19 && n <= 30)) { + find(n, size, massive); + } else { + printf("Function number %d invalid.\n", n); + } + printf("Input: "); + } +} + +int flush(void){ + int c; +while ((c = getchar()) != '\n' && c != EOF) + if (c == 4 || c == 3) return 1; +if (c == EOF) return 1; +return 0; +} diff --git a/proglabs/lab8/func/range.c b/proglabs/lab8/func/range.c new file mode 100644 index 0000000..e95cfce --- /dev/null +++ b/proglabs/lab8/func/range.c @@ -0,0 +1,178 @@ +#include "func.h" + +void range(int type,int size, int *massive){ + int x, k, m; + +switch(type){ + case 1: + k = massive[0]; + m = massive[0]; + printf("\tFinding max and min int in massive.\n"); + + for(int i = 0;imassive[i])?m:massive[i]; + k = (ksize-1|| k>m){ + if(k<0)printf("min cannot be below 0!\n"); + if(m>size)printf("max cannot be bigger %d!\n",size); + if(k>m)printf("min cannot be bigger than max!\n"); + if(flush())return; + printf("Input: "); + } + if(flush())return; + x=massive[k]; + for(int i = k;i<=m;i++){ + x = (x>massive[i])?x:massive[i]; + } + printf("Max massive int betveen [%d] and [%d] is %d.\n\n",k,m,x); + break; + + + case 3: + printf("\tEnter Range where find min int.\n"); + printf("Input: min max\nInput: "); + while(scanf(" %d %d", &k, &m)!=2 || k<0 || m>size-1 || k>m){ + if(k<0)printf("min cannot be below 0!\n"); + if(m>size)printf("max cannot be bigger %d!\n",size); + if(k>m)printf("min cannot be bigger than max!\n"); + if(flush())return; + } + if(flush())return; + x = massive[k]; + for(int i = k;i<=m;i++){ + x = (xk){printf("[%3d]\t{%p}\n",i,&massive[i]);x++;} + } + if(x==0)printf("int > %d not found.",k); + break; + + + case 5: + printf("\tInput int to find all lower int.\n"); + printf("\nInput: "); + while(scanf(" %d", &k)!=1) + if(flush())return; + if(flush())return; + x = 0; + for(int i = 0;isize-1|| k>m){ + if(k<0)printf("min cannot be below 0!\n"); + if(m>size)printf("max cannot be bigger %d!\n",size); + if(k>m)printf("min cannot be bigger than max!\n"); + if(flush())return; + printf("Input: "); + } + if(flush())return; + x=massive[k]; + for(int i = k;i<=m;i++){ + x += massive[i]; + } + printf("Sum betveen [%d] and [%d] is %d.\n\n",k,m,x); + break; + + case 11: + case 12: + printf("\tEnter Range where find arithmetic mean\\n.\n"); + printf("Input: min max\nInput: "); + while(scanf(" %d %d", &k, &m)!=2 || k<0 || m>size-1|| k>m){ + if(k<0)printf("min cannot be below 0!\n"); + if(m>size)printf("max cannot be bigger %d!\n",size); + if(k>m)printf("min cannot be bigger than max!\n"); + if(flush())return; + printf("Input: "); + } + if(flush())return; + x=massive[k];int c=0; + for(int i = k;i<=m;i++){ + x += massive[i]; + c++; + } + x /= c; + printf("arithmetic mean betveen [%d] and [%d] is %d.\n\n",k,m,x); + break; + + + case 13: + k = massive[0]; + m = massive[0]; + printf("\tFinding max and min int in massive.\n"); + + for(int i = 0;imassive[i])?m:massive[i]; + k = (ksize-1|| k>m){ + if(k<0)printf("min cannot be below 0!\n"); + if(m>size)printf("max cannot be bigger %d!\n",size); + if(k>m)printf("min cannot be bigger than max!\n"); + if(flush())return; + printf("Input: "); + } + if(flush())return; + for(int i = k;isize-1|| k>m){ + if(k<0)printf("min cannot be below 0!\n"); + if(m>size)printf("max cannot be bigger %d!\n",size); + if(k>m)printf("min cannot be bigger than max!\n"); + if(flush())return; + printf("Input: "); + } + if(flush())return; + k = massive[k]; + m = massive[k]; + for(int i = k;imassive[i])?m:massive[i]; + k = (k