lmao
This commit is contained in:
@@ -1 +1 @@
|
||||
gcc -std=c99 -Wall main.c ./func/get.c ./func/massive.c ./func/menu.c ./func/special.c -o prog
|
||||
gcc -std=c99 -Wall main.c ./func/get.c ./func/massive.c ./func/menu.c ./func/special.c ./func/func.c -o prog
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
#include "func.h"
|
||||
|
||||
void func(int x, int (*massive)[COL]){
|
||||
int r, c, i, t, ixac, ixar, ixbc, ixbr, one, two;
|
||||
int a, b, min, max;
|
||||
int inbuff = 0, null = 0;
|
||||
int buff[5];
|
||||
|
||||
switch(x){
|
||||
case 31:
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch min and max in massive:");
|
||||
min = max = a = *(*(massive)); ixar = 0; ixac = 0;
|
||||
for(c = 0; c < COL; c++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
a = *(*(massive + c) + r);
|
||||
if(a < min){ min = a; ixac = c; ixar = r; }
|
||||
if(a > max){ max = a; ixbc = c; ixbr = r; }
|
||||
}
|
||||
}
|
||||
printf("\n\tResult: Min:[%lc] | Index [%d;%d]\nMax:[%lc] | Index:[%d;%d]", min, ixac, ixar, max, ixbc, ixbr);
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 32:
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch max in every row and column:");
|
||||
b = a = *(*(massive));
|
||||
for(c = 0; c < COL; c++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
a = *(*(massive + c) + r);
|
||||
if(a > b){ b = a; ixac = c; ixar = r; }
|
||||
}
|
||||
printf("\n\tColumn [%d] | Max: %lc | Index [%d;%d]", c, b, ixac, ixar);
|
||||
}
|
||||
b = a = *(*(massive));
|
||||
for(r = 0; r < ROW; r++){
|
||||
for(c = 0; c < COL; c++){
|
||||
a = *(*(massive + c) + r);
|
||||
if(a > b){ b = a; ixac = c; ixar = r; }
|
||||
}
|
||||
printf("\n\tRow [%d] | Max: %lc | Index [%d;%d]", r, b, ixac, ixar);
|
||||
}
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 33:
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch [] > input");
|
||||
inp;
|
||||
if((i = buffinput(&null, &inbuff, buff)) == -1){ flush(); return; }
|
||||
a = *buff;
|
||||
for(c = 0; c < COL; c++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
b = *(*(massive + c) + r);
|
||||
if(b > a)
|
||||
printf("\n\tResult: [%lc] > %lc | Index [%d;%d]", b, a, c, r);
|
||||
}
|
||||
}
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 34:
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch [] < input");
|
||||
inp;
|
||||
if((i = buffinput(&null, &inbuff, buff)) == -1){ return; }
|
||||
a = *buff;
|
||||
for(c = 0; c < COL; c++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
b = *(*(massive + c) + r);
|
||||
if(b < a)
|
||||
printf("\n\tResult: [%lc] < %lc | Index [%d;%d]", b, a, c, r);
|
||||
}
|
||||
}
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 35:
|
||||
t = 0;
|
||||
do{
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch [] > input in Columns Between m and l");
|
||||
finp; printf("k m l\t m & l should be 0-9\n");
|
||||
finp;
|
||||
if((i = buffinput(&null, &inbuff, buff)) == -1){ return; }
|
||||
a = *buff;
|
||||
one = *(buff + 2);
|
||||
two = *(buff + 4);
|
||||
if(one > two){ one = -1; }
|
||||
} while(!(two >= '0' && two <= '9') && !(one >= '0' && one <= '9'));
|
||||
printf("\nSearch [] > %lc in Columns %lc-%lc", a, one, two);
|
||||
for(; one <= two; one++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
b = *(*(massive + (one - '0')) + r);
|
||||
if(b > a){
|
||||
printf("\n\tResult: [%lc] > %lc | Index [%d;%d]", b, a, one - '0', r); t++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(t == 0) printf("\n\t[] > %lc not found.", a);
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 36:
|
||||
t = 0;
|
||||
do{
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch [] > input in Rows Between m and l");
|
||||
finp; printf("k m l\t m & l should be 0-9\n");
|
||||
finp;
|
||||
if((i = buffinput(&null, &inbuff, buff)) == -1){ return; }
|
||||
a = *buff;
|
||||
one = *(buff + 2);
|
||||
two = *(buff + 4);
|
||||
if(one > two){ one = -1; }
|
||||
} while(!(two >= '0' && two <= '9') && !(one >= '0' && one <= '9'));
|
||||
printf("\nSearch [] > %lc in Rows %lc-%lc", a, one, two);
|
||||
for(; one <= two; one++){
|
||||
for(c = 0; c < COL; c++){
|
||||
b = *(*(massive + c) + (one - '0'));
|
||||
if(b > a){
|
||||
printf("\n\tResult: [%lc] > %lc | Index [%d;%d]", b, a, c, one - '0'); t++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(t == 0) printf("\n\t[] > %lc not found.", a);
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 37:
|
||||
t = 0;
|
||||
do{
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch [] < input in Columns Between m and l");
|
||||
finp; printf("k m l\t m & l should be 0-9\n");
|
||||
finp;
|
||||
if((i = buffinput(&null, &inbuff, buff)) == -1){ return; }
|
||||
a = *buff;
|
||||
one = *(buff + 2);
|
||||
two = *(buff + 4);
|
||||
if(one > two){ one = -1; }
|
||||
} while(!(two >= '0' && two <= '9') && !(one >= '0' && one <= '9'));
|
||||
printf("\nSearch [] < %lc in Columns %lc-%lc", a, one, two);
|
||||
for(; one <= two; one++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
b = *(*(massive + (one - '0')) + r);
|
||||
if(b < a){
|
||||
printf("\n\tResult: [%lc] < %lc | Index [%d;%d]", b, a, one - '0', r); t++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(t == 0) printf("\n\t[] < %lc not found.", a);
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 38:
|
||||
t = 0;
|
||||
do{
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch [] < input in Rows Between m and l");
|
||||
finp; printf("k m l\t m & l should be 0-9\n");
|
||||
finp;
|
||||
if((i = buffinput(&null, &inbuff, buff)) == -1){ return; }
|
||||
a = *buff;
|
||||
one = *(buff + 2);
|
||||
two = *(buff + 4);
|
||||
if(one > two){ one = -1; }
|
||||
} while(!(two >= '0' && two <= '9') && !(one >= '0' && one <= '9'));
|
||||
printf("\nSearch [] < %lc in Rows %lc-%lc", a, one, two);
|
||||
for(; one <= two; one++){
|
||||
for(c = 0; c < COL; c++){
|
||||
b = *(*(massive + c) + (one - '0'));
|
||||
if(b < a){
|
||||
printf("\n\tResult: [%lc] < %lc | Index [%d;%d]", b, a, c, one - '0'); t++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(t == 0) printf("\n\t[] < %lc not found.", a);
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 39:
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSearch all [] between Min & Max in massive.");
|
||||
min = max = a = *(*(massive)); ixac = 0; ixar = 0;
|
||||
for(c = 0; c < COL; c++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
a = *(*(massive + c) + r);
|
||||
if(a < min){ min = a; ixac = c; }
|
||||
if(a > max){ max = a; ixar = r; }
|
||||
}
|
||||
}
|
||||
for(c = 0; c < COL; c++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
if((*(*(massive + c) + r)) >= min && (*(*(massive + c) + r) <= max)){
|
||||
printf("\n\tResult: [%lc] | Index [%d|%d]", *(*(massive + c) + r), c, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
inp;
|
||||
break;
|
||||
|
||||
case 310:
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
int max = *(*(massive));
|
||||
for(c = 0; c < COL; c++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
if(*(*(massive + c) + r) > max)
|
||||
max = *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
printf("\nInput k <= max value %lc: ", max);
|
||||
finp;
|
||||
if((i = buffinput(&null, &inbuff, buff)) == -1){ return; }
|
||||
a = *buff;
|
||||
if(a > max){
|
||||
printf("\nError: k > max value. Try again.");
|
||||
}
|
||||
} while(a > max);
|
||||
for(c = 0; c < COL; c++){
|
||||
for(r = 0; r < ROW; r++){
|
||||
if(*(*(massive + c) + r) % a == 0){
|
||||
printf("\nResult: [%lc] | Index [%d;%d]", *(*(massive + c) + r), c, r);
|
||||
}}}
|
||||
inp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void func2(int x, int (*massive)[COL]){
|
||||
int r,c,sum,i;
|
||||
int inbuff = 0, null = 0;
|
||||
int buff[5];
|
||||
int k;
|
||||
|
||||
switch(x){
|
||||
|
||||
case 311:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of even []");
|
||||
for (c = 0; c < COL; c++){
|
||||
for (r = 0; r < ROW; r++){
|
||||
if ((*(*(massive + c) + r)) % 2 == 0)
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 312:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of odd []");
|
||||
for (c = 0; c < COL; c++){
|
||||
for (r = 0; r < ROW; r++){
|
||||
if ((*(*(massive + c) + r)) % 2 != 0)
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 313:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of []%%k");
|
||||
finp;
|
||||
|
||||
if ((i = buffinput(&null, &inbuff, buff)) == -1) return;
|
||||
k = *buff;
|
||||
|
||||
for (c = 0; c < COL; c++){
|
||||
for (r = 0; r < ROW; r++){
|
||||
if ((*(*(massive + c) + r)) % k == 0)
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 314:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of [] column%%2==0");
|
||||
|
||||
for (c = 0; c < COL; c += 2){
|
||||
for (r = 0; r < ROW; r++){
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 315:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of [] column%%2!=0");
|
||||
|
||||
for (c = 1; c < COL; c += 2){
|
||||
for (r = 0; r < ROW; r++){
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 316:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of [] rows%%2==0");
|
||||
|
||||
for (c = 0; c < COL; c++){
|
||||
for (r = 0; r < ROW; r += 2){
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 317:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of [] rows%%2!=0");
|
||||
|
||||
for (c = 0; c < COL; c++){
|
||||
for (r = 1; r < ROW; r += 2){
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 318:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of [] above main diagonal");
|
||||
|
||||
for (c = 0; c < COL; c++){
|
||||
for (r = 0; r <= c; r++){
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 319:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of [] below main diagonal");
|
||||
|
||||
for (c = 0; c < COL; c++){
|
||||
for (r = c; r < ROW; r++){
|
||||
sum += *(*(massive + c) + r);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
|
||||
|
||||
case 320:
|
||||
sum = 0;
|
||||
clear();
|
||||
seeMassive(massive);
|
||||
printf("\nSumm of [] on both diagonals");
|
||||
|
||||
for (c = 0; c < COL; c++){
|
||||
sum += *(*(massive + c) + c);
|
||||
sum += *(*(massive + c) + (ROW - 1 - c));
|
||||
}
|
||||
|
||||
printf("\n\tResult: sum %d", sum);
|
||||
inp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,18 @@
|
||||
#define COL 10
|
||||
#define ROW 10
|
||||
|
||||
#define inp printf("\nInput: ");
|
||||
#define finp printf("\nFunction Input: ");
|
||||
|
||||
// GET
|
||||
int mainget(void);
|
||||
int numget(void);
|
||||
int getsymb(int *b,wchar_t *buff);
|
||||
int buffinput(int *cell, int *inbuf, int *buff);
|
||||
|
||||
// MASSIVE
|
||||
void seeMassive(wchar_t (*massive)[COL]);
|
||||
void setMassive(int x, wchar_t (*massive)[COL]);
|
||||
void func(int x, wchar_t (*massive)[COL]);
|
||||
void seeMassive(int (*massive)[COL]);
|
||||
void setMassive(int x, int (*massive)[COL]);
|
||||
void func(int x, int (*massive)[COL]);
|
||||
void func2(int x, int (*massive)[COL]);
|
||||
|
||||
// MENU
|
||||
void helpMenu(void);
|
||||
@@ -27,5 +30,13 @@ void funcMenu(void);
|
||||
void clear(void);
|
||||
int flush(void);
|
||||
int end(int c);
|
||||
|
||||
|
||||
//Massive View
|
||||
#define intervalincell 1
|
||||
#define intervalx 2
|
||||
#define intervaly 2
|
||||
#define symb1 '*'
|
||||
#define symb2 '*'
|
||||
#define symb3 ' '
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef FUNC
|
||||
#define FUNC
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <locale.h>
|
||||
#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
|
||||
+28
-23
@@ -4,14 +4,14 @@ int mainget(void){
|
||||
int t=0,x,y=0,num=0;
|
||||
unsigned long input = 0;
|
||||
while(
|
||||
((x=getchar())>=32 && t<100)
|
||||
((x=getwchar())>=32 && t<100)
|
||||
&& ((x>='a' && x<='z')
|
||||
|| (x>='0' && x<= '9')
|
||||
|| (x>='A' && x<='Z'))){
|
||||
// printf("%d %lu ",x,input);
|
||||
//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);
|
||||
//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--;}
|
||||
@@ -19,7 +19,6 @@ int mainget(void){
|
||||
t++;
|
||||
if(end(x))return -1;
|
||||
}
|
||||
|
||||
if(end(x))return -1;
|
||||
|
||||
int exit = 69887384;
|
||||
@@ -56,27 +55,33 @@ int mainget(void){
|
||||
|
||||
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++;
|
||||
int buffinput(int *cell, int *inbuff, int *buff){
|
||||
setlocale(LC_ALL, "");
|
||||
wint_t ch;
|
||||
*inbuff = 0;
|
||||
while((ch=getwchar())!='\n'&&*inbuff<5){
|
||||
*(buff+*inbuff)=(int)ch;
|
||||
(*inbuff)++;
|
||||
}
|
||||
//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++;
|
||||
// -num- -select cell ----------------------------
|
||||
if(*buff == '-'){
|
||||
*cell = 0;
|
||||
for(int i = 1;i<(*inbuff);i++){
|
||||
if( *(buff+i) >= '0' && *(buff+i) <= '9'){
|
||||
*cell = ((*cell)*10) + ((*(buff+i))- '0');
|
||||
if(*cell>99){*cell=0;}}
|
||||
else if (*(buff+i)!='-') {*cell = 0;break;}
|
||||
}
|
||||
if(*(buff+4)=='-')
|
||||
if(t==4)return 1;
|
||||
}
|
||||
t=0;
|
||||
getchar();
|
||||
if(*(buff+(*inbuff-1))=='-'&&*cell>-1)return 1;
|
||||
//-------------------------------------------------
|
||||
|
||||
// exit -------------------------------------------
|
||||
if (*buff =='e'&&
|
||||
*(buff+1)=='x'&&
|
||||
*(buff+2)=='i'&&
|
||||
*(buff+3)=='t'){return -1;}
|
||||
//-------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
#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;
|
||||
}
|
||||
+588
-60
@@ -1,79 +1,607 @@
|
||||
#include "func.h"
|
||||
|
||||
void seeMassive(wchar_t (*massive)[COL]){
|
||||
printf("\t\t\tMassive\n\n[ ] ");
|
||||
for(int i = 0;i<COL;i++)
|
||||
printf("[%d] ",i);
|
||||
putchar('\n');putchar('\n');
|
||||
|
||||
for(int i = 0;i<ROW;i++){
|
||||
printf("[%d] ",i);
|
||||
for(int j = 0;j<COL;j++){
|
||||
printf("[%lc] ",*(*(massive+i)+j));
|
||||
#define intervalin for(int i = 0;i<intervalincell;i++)putchar(symb3);
|
||||
#define intervaln for(int i = 0;i<intervaly;i++)putchar('\n');
|
||||
#define intervalbt for(int i = 0;i<intervalx;i++)putchar(symb3);
|
||||
|
||||
void mseehelp(int i){
|
||||
putchar(symb1);
|
||||
intervalin;
|
||||
printf("%lc",i);
|
||||
intervalin;
|
||||
putchar(symb2);
|
||||
intervalbt;
|
||||
}
|
||||
void cseehelp(int i){
|
||||
putchar('[');
|
||||
intervalin;
|
||||
putwchar(i);
|
||||
intervalin;
|
||||
putchar(']');
|
||||
intervalbt;
|
||||
}
|
||||
|
||||
void seeMassive(int (*massive)[COL]){
|
||||
printf("\t\t\tMassive\n");
|
||||
|
||||
//corner null
|
||||
cseehelp(symb3);
|
||||
|
||||
// top 0-9
|
||||
for(char i = '0';i<=(COL+'0');i++){
|
||||
if(i!=COL+'0')cseehelp(i);
|
||||
else cseehelp(symb3);
|
||||
}
|
||||
intervaln;
|
||||
|
||||
// Massive
|
||||
for(char i = '0';i<=(ROW+'0');i++){
|
||||
if(i!=ROW+'0'){
|
||||
cseehelp(i);//left 0-9
|
||||
for(char j = '0';j<(COL+'0');j++){
|
||||
mseehelp(*(*(massive+(i-'0'))+(j-'0')));//symbols
|
||||
|
||||
}
|
||||
cseehelp(i);//right 0-9
|
||||
intervaln;
|
||||
}
|
||||
putchar('\n');putchar('\n');
|
||||
else{ // bottom 0-9
|
||||
cseehelp(symb3);
|
||||
for(char i = '0';i<=(COL+'0');i++){
|
||||
if(i!=COL+'0')cseehelp(i);
|
||||
else cseehelp(symb3);
|
||||
}
|
||||
intervaln;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void setMassive(int x, wchar_t (*massive)[COL]){
|
||||
int b,c,o,e,cell=0;
|
||||
wchar_t buff[5];
|
||||
switch(x){
|
||||
void setMassive(int settype, int (*massive)[COL]){
|
||||
int re, inbuff=0, buffcmd=1, cell=-1;
|
||||
int x=0,y=0,st=0;
|
||||
int row=0,col=0;
|
||||
int buff[5];
|
||||
switch(settype){
|
||||
case 21:
|
||||
for(int col = 0;col<COL;col++){
|
||||
for(int row = 0;row<ROW;row++){
|
||||
o = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = 'X';
|
||||
seeMassive(massive);
|
||||
printf("Massive Input: ");
|
||||
|
||||
e=getsymb(&b,buff);
|
||||
if(e==-1)c=' ';
|
||||
|
||||
if(e==1){
|
||||
for(int i = 1;i<4;i++)
|
||||
cell = (cell*10)+(buff[i]-'0');
|
||||
if(cell>ROW*COL-1)
|
||||
printf("Error cell cannot be bigger %d",ROW*COL-1);
|
||||
else while(cell>0){
|
||||
col = row = 0;
|
||||
if(col<COL)col++;
|
||||
else {row++;col=0;}
|
||||
while(buffcmd!=-1){
|
||||
if(row==-1)row=9;
|
||||
re = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = 'X';
|
||||
clear();
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
if(row<ROW&&col<COL){
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row++;}
|
||||
else if(col<COL-1){
|
||||
row=0;col++;
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row++;}
|
||||
else buffcmd=-1;
|
||||
}
|
||||
}
|
||||
|
||||
if(e==0){
|
||||
for(int i = 0;i<b;i++){
|
||||
if(col<COL){
|
||||
printf("Z");
|
||||
*(*(massive+col)+row)=buff[i];
|
||||
col++;
|
||||
getchar();
|
||||
}
|
||||
else if(row<ROW){
|
||||
col=0;
|
||||
row++;
|
||||
*(*(massive+col)+row)=buff[i];
|
||||
}
|
||||
else c = ' ';
|
||||
break;
|
||||
case 1:
|
||||
*(*(massive+col)+row) = re;
|
||||
row = col = 0;
|
||||
for(;cell>0;){
|
||||
if((cell-10)>=0){cell-=10;col++;}
|
||||
else {cell--;row++;}
|
||||
}
|
||||
}
|
||||
|
||||
if(c==' '){*(*(massive+col)+row) = o;break;}
|
||||
}
|
||||
if(c==' ')break;
|
||||
}
|
||||
helpMenu();
|
||||
*(*(massive+col)+row) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
case 22:
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+col)+(row+9));
|
||||
*(*(massive+col)+(row+9)) = 'X';
|
||||
clear();
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
if(row>(ROW*-1)&&col<COL){
|
||||
*(*(massive+col)+(row+9))=*(buff+i);
|
||||
row--;
|
||||
if(row==-10){row=0;col++;}
|
||||
}
|
||||
else buffcmd=-1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
*(*(massive+col)+(row+9)) = re;
|
||||
row =0; col = 0;
|
||||
for(;cell>0;cell--){
|
||||
if((cell-10)>=0){cell-=10;col++;}
|
||||
else {cell--;row--;}
|
||||
}
|
||||
}
|
||||
}
|
||||
*(*(massive+col)+(row+9)) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
case 23:
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = 'X';
|
||||
clear();
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
if(row<ROW&&col<COL){
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
col++;
|
||||
if(col==10){col=0;row++;}
|
||||
}
|
||||
else buffcmd=-1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
*(*(massive+col)+row) = re;
|
||||
row = 0; col = 0;
|
||||
for(;cell>0;){
|
||||
if((cell-10)>=0){cell-=10;row++;}
|
||||
else {cell--;col++;}
|
||||
}
|
||||
}
|
||||
}
|
||||
*(*(massive+col)+row) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
case 24:
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+(col+9))+row);
|
||||
*(*(massive+(col+9))+row) = 'X';
|
||||
clear();
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
if(row<ROW&&col>(COL*-1)){
|
||||
*(*(massive+(col+9))+row)=*(buff+i);
|
||||
col--;
|
||||
printf("\t%d %d\n",col,col+9);
|
||||
if(col==-10){col=0;row++;}
|
||||
}
|
||||
else buffcmd=-1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
*(*(massive+(col+9))+row) = re;
|
||||
row = 0; col = 0;
|
||||
for(;cell>0;){
|
||||
if((cell-10)>=0){cell-=10;row++;}
|
||||
else {cell--;col--;}
|
||||
}
|
||||
}
|
||||
}
|
||||
*(*(massive+(col+9))+row) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
case 25:
|
||||
x=1,y=1,st=1;
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = '@';
|
||||
clear();
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
switch(st){
|
||||
case 1:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row++;
|
||||
if(row==COL-y){st=2;}
|
||||
break;
|
||||
case 2:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
col++;
|
||||
if(col==row)st=3;
|
||||
break;
|
||||
case 3:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row--;
|
||||
if(row==x-1){st=4;y++;}
|
||||
break;
|
||||
case 4:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
if(row==4&&col==5)st=0;
|
||||
col--;
|
||||
if(col==row+1){st=1;x++;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
break;
|
||||
}}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
*(*(massive+col)+row) = re;
|
||||
col=row=0;x=y=1;st=1;
|
||||
for(;cell>0;cell--){
|
||||
switch(st){
|
||||
case 1:
|
||||
row++;
|
||||
if(row==COL-y){st=2;}
|
||||
break;
|
||||
case 2:
|
||||
col++;
|
||||
if(col==row)st=3;
|
||||
break;
|
||||
case 3:
|
||||
row--;
|
||||
if(row==x-1){st=4;y++;}
|
||||
break;
|
||||
case 4:
|
||||
if(row==4&&col==5)st=0;
|
||||
col--;
|
||||
if(col==row+1){st=1;x++;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*(*(massive+col)+row) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
default:printf("Eror setmassive-%d\n",x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void func(int x, wchar_t (*massive)[COL]){
|
||||
switch(x){
|
||||
case 26:
|
||||
x=5,y=5,st=1,row=4,col=5;
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = '@';
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
switch(st){
|
||||
case 1:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row++;
|
||||
if(row==col){st=2;}
|
||||
break;
|
||||
case 2:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
col--;
|
||||
if(col==x-1)st=3;
|
||||
break;
|
||||
case 3:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row--;
|
||||
if(col==row+1){st=4;y--;}
|
||||
if(row==-1)st=0;
|
||||
break;
|
||||
case 4:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
col++;
|
||||
if(col==COL-y){st=1;x--;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
break;
|
||||
}}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
*(*(massive+col)+row) = re;
|
||||
x=5,y=5,st=1,row=4,col=5;
|
||||
for(;cell>0;cell--){
|
||||
switch(st){
|
||||
case 1:
|
||||
row++;
|
||||
if(row==col){st=2;}
|
||||
break;
|
||||
case 2:
|
||||
col--;
|
||||
if(col==x-1)st=3;
|
||||
break;
|
||||
case 3:
|
||||
row--;
|
||||
if(col==row+1){st=4;y--;}
|
||||
if(row==-1)st=0;
|
||||
break;
|
||||
case 4:
|
||||
col++;
|
||||
if(col==COL-y){st=1;x--;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
|
||||
}
|
||||
}
|
||||
*(*(massive+col)+row) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
|
||||
case 27:
|
||||
x=1,y=9,st=3,row=0,col=9;
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = 'X';
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
switch(st){
|
||||
case 1:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row++;
|
||||
if(row==x){st=2;x++;}
|
||||
break;
|
||||
case 2:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
col++;
|
||||
if(col==(COL-1)){st=3;}
|
||||
break;
|
||||
case 3:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
if(x==ROW){st=0;buffcmd=-1;}
|
||||
else{y--;col = y;row=0;st=1;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
break;
|
||||
case 1:
|
||||
*(*(massive+col)+row) = re;
|
||||
x=1,y=9,st=3,row=0,col=9;
|
||||
for(;cell>0;cell--){
|
||||
switch(st){
|
||||
case 1:
|
||||
row++;
|
||||
if(row==x){st=2;x++;}
|
||||
break;
|
||||
case 2:
|
||||
col++;
|
||||
if(col==(COL-1)){st=3;}
|
||||
break;
|
||||
case 3:
|
||||
if(x==ROW){st=0;buffcmd=-1;}
|
||||
else{y--;col = y;row=0;st=1;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
|
||||
}
|
||||
}
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
|
||||
case 28:
|
||||
x=8,y=0,st=3,row=9,col=0;
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = 'X';
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
switch(st){
|
||||
case 1:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row--;
|
||||
if(row==x){st=2;x--;}
|
||||
break;
|
||||
case 2:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
col--;
|
||||
if(col==0){st=3;}
|
||||
break;
|
||||
case 3:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
if(x==-1){st=0;buffcmd=-1;}
|
||||
else{y++;col = y;row=9;st=1;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
break;
|
||||
case 1:
|
||||
*(*(massive+col)+row) = re;
|
||||
x=8,y=0,st=3,row=9,col=0;
|
||||
for(;cell>0;cell--){
|
||||
switch(st){
|
||||
case 1:
|
||||
row--;
|
||||
if(row==x){st=2;x--;}
|
||||
break;
|
||||
case 2:
|
||||
col--;
|
||||
if(col==0){st=3;}
|
||||
break;
|
||||
case 3:
|
||||
if(x==-1){st=0;buffcmd=-1;}
|
||||
else{y++;col = y;row=9;st=1;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
}
|
||||
}
|
||||
*(*(massive+col)+row) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 29:
|
||||
x=1,y=0,st=3,row=0,col=0;
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = 'X';
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
switch(st){
|
||||
case 1:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row++;
|
||||
if(row==x){st=2;x++;}
|
||||
break;
|
||||
case 2:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
col--;
|
||||
if(col==0){st=3;}
|
||||
break;
|
||||
case 3:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
if(col==0&&row==ROW-1){st=0;buffcmd=-1;}
|
||||
else{y++;col = y;row=0;st=1;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
break;
|
||||
case 1:
|
||||
x=1,y=0,st=3,row=0,col=0;
|
||||
*(*(massive+col)+row) = re;
|
||||
for(;cell>0;cell--){
|
||||
switch(st){
|
||||
case 1:
|
||||
row++;
|
||||
if(row==x){st=2;x++;}
|
||||
break;
|
||||
case 2:
|
||||
col--;
|
||||
if(col==0){st=3;}
|
||||
break;
|
||||
case 3:
|
||||
if(col==0&&row==ROW-1){st=0;buffcmd=-1;}
|
||||
else{y++;col = y;row=0;st=1;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
|
||||
}
|
||||
}
|
||||
*(*(massive+col)+row) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
case 210:
|
||||
x=8,y=9,st=3,row=9,col=9;
|
||||
while(buffcmd!=-1){
|
||||
re = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = 'X';
|
||||
printf("\t\t\tMASSIVE EDIT\nInput:\n\t\"-num-\" to select cell\n\t \"exit\" to leave\n");
|
||||
//printf("\ncol:%d row:%d x:%d y:%d st:%d",col,row,x,y,st);
|
||||
seeMassive(massive);
|
||||
printf("Massive input: ");
|
||||
buffcmd = buffinput(&cell,&inbuff,buff);
|
||||
switch(buffcmd){
|
||||
case -1:break;
|
||||
case 0:
|
||||
for(int i = 0;i<inbuff;i++){
|
||||
switch(st){
|
||||
case 1:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
row--;
|
||||
if(row==x){st=2;x--;}
|
||||
break;
|
||||
case 2:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
col++;
|
||||
if(col==(COL-1)){st=3;}
|
||||
break;
|
||||
case 3:
|
||||
*(*(massive+col)+row)=*(buff+i);
|
||||
if(col==COL-1&&row==0){st=0;buffcmd=-1;}
|
||||
else{y--;col = y;row=9;st=1;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
break;
|
||||
case 1:
|
||||
*(*(massive+col)+row) = re;
|
||||
x=8,y=9,st=3,row=9,col=9;
|
||||
for(;cell>0;cell--){
|
||||
switch(st){
|
||||
case 1:
|
||||
row--;
|
||||
if(row==x){st=2;x--;}
|
||||
break;
|
||||
case 2:
|
||||
col++;
|
||||
if(col==(COL-1)){st=3;}
|
||||
break;
|
||||
case 3:
|
||||
if(col==COL-1&&row==0){st=0;buffcmd=-1;}
|
||||
else{y--;col = y;row=9;st=1;}
|
||||
break;
|
||||
case 0:
|
||||
buffcmd=-1;
|
||||
}}
|
||||
}
|
||||
}
|
||||
*(*(massive+col)+row) = re;
|
||||
helpMenu();printf("Input: ");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
#include "func.h"
|
||||
|
||||
void seeMassive(wchar_t (*massive)[COL]){
|
||||
printf("\t\t\tMassive\n\n[ ] ");
|
||||
for(int i = 0;i<COL;i++)
|
||||
printf("[%d] ",i);
|
||||
putchar('\n');putchar('\n');
|
||||
|
||||
for(int i = 0;i<ROW;i++){
|
||||
printf("[%d] ",i);
|
||||
for(int j = 0;j<COL;j++){
|
||||
printf("[%lc] ",*(*(massive+i)+j));
|
||||
}
|
||||
putchar('\n');putchar('\n');
|
||||
}
|
||||
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;col<COL;col++){
|
||||
for(int row = 0;row<ROW;row++){
|
||||
o = *(*(massive+col)+row);
|
||||
*(*(massive+col)+row) = 'X';
|
||||
seeMassive(massive);
|
||||
printf("Massive Input: ");
|
||||
|
||||
e=getsymb(&b,buff);
|
||||
if(e==-1)c=' ';
|
||||
|
||||
if(e==1){
|
||||
for(int i = 1;i<4;i++)
|
||||
cell = (cell*10)+(buff[i]-'0');
|
||||
if(cell>ROW*COL-1)
|
||||
printf("Error cell cannot be bigger %d",ROW*COL-1);
|
||||
else while(cell>0){
|
||||
col = row = 0;
|
||||
if(col<COL)col++;
|
||||
else {row++;col=0;}
|
||||
}
|
||||
}
|
||||
|
||||
if(e==0){
|
||||
for(int i = 0;i<b;i++){
|
||||
if(col<COL){
|
||||
printf("Z");
|
||||
*(*(massive+col)+row)=buff[i];
|
||||
col++;
|
||||
}
|
||||
else if(row<ROW){
|
||||
col=0;
|
||||
row++;
|
||||
*(*(massive+col)+row)=buff[i];
|
||||
}
|
||||
else c = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
if(c==' '){*(*(massive+col)+row) = o;break;}
|
||||
}
|
||||
if(c==' ')break;
|
||||
}
|
||||
helpMenu();
|
||||
break;
|
||||
default:printf("Eror setmassive-%d\n",x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void func(int x, wchar_t (*massive)[COL]){
|
||||
switch(x){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#include "func.h"
|
||||
|
||||
void helpMenu(void){
|
||||
clear();
|
||||
printf("Command [alias] - what it does.\n\n");
|
||||
printf("\thelp [h] - Show this info.\n\n");
|
||||
printf("\tshow [c] - Show the 2d array\n\n");
|
||||
printf("\tset [s] - Show all methods to fill the 2d array.\n");
|
||||
printf("\tset* [s*] - Choose how to fill the 2d array\n\n");
|
||||
printf("\tfunc [f] - Show all functions\n");
|
||||
printf("\tfunc* [f*] - Choose a function.\n\n");
|
||||
printf("\texit [q] - Quite the program.\n\n\n");
|
||||
}
|
||||
|
||||
void setMenu(void){
|
||||
clear();
|
||||
printf("Fill 2d massive methods\n");
|
||||
printf("\t [1] - Row‑wise left‑to‑right input.\n");
|
||||
printf("\t [2] - Row‑wise right‑to‑left input.\n\n");
|
||||
printf("\t *[3] - Column‑wise top‑to‑bottom input.\n");
|
||||
printf("\t [4] - Column‑wise bottom‑to‑top input.\n\n");
|
||||
printf("\t [5] - Spiral from outer edge toward centre.\n");
|
||||
printf("\t [6] - Spiral from centre outward.\n\n");
|
||||
printf("\t [7] - Diagonal input starting at bottom‑left corner.\n");
|
||||
printf("\t [8] - Diagonal input starting at top‑right corner.\n");
|
||||
printf("\t [9] - Diagonal input starting at top‑left corner.\n");
|
||||
printf("\t[10] - Diagonal input starting at bottom‑right corner.\n\n\n");
|
||||
}
|
||||
|
||||
void funcMenu(void){
|
||||
clear();
|
||||
printf("Functions\n");
|
||||
printf("\t [1] - Find the maximum and minimum elements of the matrix.\n");
|
||||
printf("\t [2] - Find the maximum value in each row and in each column of the matrix.\n\n");
|
||||
printf("List elements\n");
|
||||
printf("\t [3] - ... whose values are greater than a given k.\n");
|
||||
printf("\t [4] - ... whose values are less than a given k.\n");
|
||||
printf("\t [5] - ... greater than k in columns m through l.\n");
|
||||
printf("\t [6] - ... greater than k in rows m through l.\n");
|
||||
printf("\t [7] - ... less than k in columns m through l.\n");
|
||||
printf("\t [8] - ... less than k in rows m through l.\n");
|
||||
printf("\t [9] - ... whose values lie between the matrix's minimum and maximum values.\n");
|
||||
printf("\t*[10] - ... that are multiples of the entered number k\n\t\t(k < matrix max; also display the matrix's maximum value).\n\n");
|
||||
printf("Compute the sum of\n");
|
||||
printf("\t[11] - ... all even elements of the matrix.\n");
|
||||
printf("\t[12] - ... odd elements of the matrix.\n");
|
||||
printf("\t[13] - ... elements that are multiples of k.\n");
|
||||
printf("\t[14] - ... elements in even‑indexed columns of the matrix.\n");
|
||||
printf("\t[15] - ... elements in odd‑indexed columns of the matrix.\n");
|
||||
printf("\t*[16] - ... elements in even‑indexed rows of the matrix.\n");
|
||||
printf("\t[17] - ... elements in odd‑indexed rows of the matrix.\n");
|
||||
printf("\t[18] - ... elements on and above the main diagonal (inclusive).\n");
|
||||
printf("\t[19] - ... elements on and below the main diagonal (inclusive).\n");
|
||||
printf("\t[20] - ... elements on both the main and secondary diagonals of the matrix.\n\n\n");
|
||||
}
|
||||
@@ -7,12 +7,12 @@ void clear(void){
|
||||
|
||||
int flush(void){
|
||||
int c;
|
||||
while ((c = getchar()) != '\n')
|
||||
while ((c = getwchar()) != '\n')
|
||||
if (c<32 && c!='\t') return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int end(int c){
|
||||
if (c<32 && c!= '\n' && c!='\t') return 1;
|
||||
return 0;
|
||||
if (c<32 && c!= L'\n' && c!=L'\t') return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <locale.h>
|
||||
|
||||
void buffinput(int *inbuff, int *buff){
|
||||
setlocale(LC_ALL, "");
|
||||
wint_t ch;
|
||||
*inbuff = 0;
|
||||
|
||||
while((ch = getwchar()) != L'\n' && *inbuff < 5){
|
||||
buff[*inbuff] = (int)ch;
|
||||
(*inbuff)++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
int buff[5];
|
||||
int inbuff = 0;
|
||||
buffinput(&inbuff, buff);
|
||||
for(int i = 0; i < inbuff; i++)
|
||||
printf("%lc - %d ", buff[i], buff[i]);
|
||||
printf("стопор");
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
||||
|
||||
+14
-12
@@ -3,33 +3,35 @@ int chooseMassiveInput();
|
||||
|
||||
int main(){
|
||||
int x;
|
||||
|
||||
|
||||
setlocale(LC_ALL, "en_US.UTF-8");
|
||||
|
||||
wchar_t massive[ROW][COL];
|
||||
//massive data
|
||||
int massive[ROW][COL];
|
||||
for(int i = 0;i<ROW;i++)
|
||||
for(int j = 0;j<COL;j++)
|
||||
*(*(massive+i)+j)=L'0';
|
||||
*(*(massive+i)+j)='0';
|
||||
//
|
||||
|
||||
clear();
|
||||
helpMenu();
|
||||
printf("Input: ");
|
||||
inp
|
||||
while((x=mainget())!=-1){
|
||||
|
||||
if(x==1){
|
||||
helpMenu();printf("Input: ");}
|
||||
helpMenu();inp;}
|
||||
|
||||
else if(x==2 || (x>=21 && x<=29) || x==210){
|
||||
if(x==2){setMenu();printf("Input: X");}
|
||||
else setMassive(x,massive);
|
||||
if(x==2){setMenu();inp;}
|
||||
else {setMassive(x,massive);flush();}
|
||||
}
|
||||
|
||||
else if(x==3 || (x>=31 && x<=39) || (x>=310 && x<=320)){
|
||||
if(x==3) {funcMenu();printf("Input: ");}
|
||||
else if(x==3 || (x>=31 && x<=39) || x==310){
|
||||
if(x==3) {funcMenu();inp;}
|
||||
else func(x,massive);
|
||||
}
|
||||
|
||||
else if((x>=311)&&(x<=320)){func2(x,massive);}
|
||||
else if(x==4){
|
||||
seeMassive(massive);printf("Input: ");
|
||||
seeMassive(massive);inp;
|
||||
}
|
||||
|
||||
else {printf("Input Error \"%d\" is undefind command.\n",x);
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#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<ROW;i++)
|
||||
for(int j = 0;j<COL;j++)
|
||||
*(*(massive+i)+j)=L'0';
|
||||
clear();
|
||||
helpMenu();
|
||||
printf("Input: ");
|
||||
while((x=mainget())!=-1){
|
||||
|
||||
if(x==1){
|
||||
helpMenu();printf("Input: ");}
|
||||
|
||||
else if(x==2 || (x>=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;
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user