lab9
This commit is contained in:
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
gcc -std=c99 -Wall main.c ./func/get.c ./func/massive.c ./func/menu.c ./func/special.c -o prog
|
||||||
@@ -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
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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]){
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,19 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user