This commit is contained in:
2025-11-21 03:45:38 +07:00
parent d219cc1a7b
commit 5cbfe19d48
12 changed files with 242 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
gcc -std=c99 -Wall main.c ./func/get.c ./func/massive.c ./func/menu.c ./func/special.c -o prog
+30
View File
@@ -0,0 +1,30 @@
#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);
// 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
+58
View File
@@ -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;
}
+29
View File
@@ -0,0 +1,29 @@
#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');
}
printf("\n\nInput: ");
return;
}
void setMassive(int x, wchar_t (*massive)[COL]){
}
void func(int x, wchar_t (*massive)[COL]){
}
+21
View File
@@ -0,0 +1,21 @@
#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 [see] - 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();
}
void funcMenu(void){
clear();
}
+18
View File
@@ -0,0 +1,18 @@
#include "func.h"
void clear(void){
printf("\033[H\033[J");
}
int flush(void){
int c;
while ((c = getchar()) != '\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;
}
+38
View File
@@ -0,0 +1,38 @@
#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' ';
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();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;
}
BIN
View File
Binary file not shown.
View File