开发的一个库

mtl.h

/*

           MMM               MMM     TTTTTTTTTTTTTTTTTT    LLL
          MMMMM           MMMMM     TTTTTTTTTTTTTTTTTT    LLL
         MMMMMMM       MMM MMM            TTT            LLL
        MMM   MMM   MMM   MMM            TTT            LLL
       MMM     MMMMM     MMM            TTT            LLL
      MMM      MMM      MMM            TTT            LLL
     MMM      MMM      MMM            TTT            LLL
    MMM      MMM      MMM            TTT            LLL
   MMM      MMM      MMM            TTT            LLLLLLLLLLLLLL
  MMM      MMM      MMM            TTT            LLLLLLLLLLLLLL

					   my template library


╭───┬────────────────────────────────────────────────────────────────╮
│VER│v1.0.3                                                          │
├───┼────────────────────────────────────────────────────────────────┤
|da │2024/5/3                                                        │
|ta │                                                                │
├───┼────────────────────────────────────────────────────────────────┤
│   │Q:what is MTL?                                                  │
│ i │A:MTL (my template library) is a C++ template library, which can|
| n | quickly develop C++ programs.                                  │  
│ f │Q:How to use MTL?                                               │
│ o │A:In C++ programs that require MTL, add #include "mtl.h" to the |
|   |    beginning of the file. And all functions are in the namespac|
|   |    e mtl, just use the mtl:: function name.                    |
├───┼────────────────────────────────────────────────────────────────┤
|   |mtl::print and mtl::println usage instructions:                 |
|   |    The syntax is the same as std::p rintf, and you can use form|
|   |    atters such as %d, %f, and %s.                              |
| T ├──────────────────────────────────────────────────────────────-─┤
| i |mtl::pass and mtl::informations::help function instructions:    |
| P |    Please use Windows, otherwise it will not work!!            |
| s ├──────────────────────────────────────────────────────────────-─┤
|   |mtl::maxs and mtl::mins usage instructions:                     |
|   |    Because variable-length parameters are used, please do not u|
|   |    se arrays                                                   |
|   ├──────────────────────────────────────────────────────────────-─┤
|   |mtl::algorithm::BinaryTree and mtl::algorithm::Tree usage instru|
|   |ctions:                                                         |
|   |    Please write your own traversal function!!                  |
├───┼──────────────────────────────────────────────────────────────-─┤
| w |Be sure to use Windows!! Otherwise, the help and pass functions |
| a |cannot be used!!                                                |
| r |Be sure to use Windows!! Otherwise, the help and pass functions |
| n |cannot be used!!                                                |
╰───┴────────────────────────────────────────────────────────────────╯

*/
#pragma once
// 是Windows系统

// 导入std中的库
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdexcpt.h>
// 非标准库
#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS
#include <conio.h>
#endif

#include "mtl_def.h"
// mtl(my template library)
namespace mtl
{
#if useprint
	// 边长型参会吧?
	void print(const char *format, ...)
	{
		va_list args;
		va_start(args, format);
		vprintf(format, args);
		va_end(args);
	}
	void println(const char *format, ...)
	{
		va_list args;
		va_start(args, format);
		vprintf(format, args);
		print("\n");
		va_end(args);
	}
#endif
#ifndef _WIN32

	// 暂停程序
	void _pass()
	{
		mtl::println("Please press any key to continue...");
		getch();
	}

	// 暂停程序
	void pass()
	{
		mtl::_pass();
	}
#endif
	// 求n个数的和
	template <typename T>
	double adds(const T &init, const T &value, ...)
	{
		return (init + value);
	}
	// 最大值
	template <typename T1, typename T2>
	double max(T1 a, T2 b)
	{
		return a > b ? a : b;
	}
	// 最小值
	template <typename T1, typename T2>
	double min(T1 a, T2 b)
	{
		return a < b ? a : b;
	}
	// 多个数求最大值
	template <typename T, typename... Args>
	double maxs(T a, Args... args)
	{
		double max = a;
		for (auto &arg : {args...})
			max = (arg > max ? arg : max);
		return max;
	}
	// 多个数求最小值
	template <typename T, typename... Args>
	double mins(T a, Args... args)
	{
		double min = a;
		for (auto &arg : {args...})
			min = (arg < min ? arg : max);
		return min;
	}
	// 高斯求和
	long gaussian_sum(int n)
	{
		int sum = 0;
		for (int i = 0; i <= n; i++)
		{
			sum += i;
		}
		return sum;
	}
	// 判断是否是回文
	bool isPalindromic(const char *str)
	{
		int len = strlen(str);
		for (int i = 0; i < len / 2; i++)
		{
			if (str[i] != str[len - i - 1])
				return false;
		}
		return true;
	}
	// 判断是否是回文
	bool isPalindromic(int num)
	{
		char str[20];
		sprintf(str, "%d", num);
		return isPalindromic(str);
	}

	inline namespace types
	{

		// 类型判断
		type_t type(unsigned int a)
		{
			return mtl::types::type_t::unsigned_int_t;
		}

		type_t type(signed int a)
		{
			return mtl::types::type_t::signed_int_t;
		}

		type_t type(unsigned short a)
		{
			return mtl::types::type_t::unsigned_short_t;
		}

		type_t type(signed short a)
		{
			return mtl::types::type_t::signed_short_t;
		}

		type_t type(unsigned long a)
		{
			return mtl::types::type_t::unsigned_long_t;
			;
		}

		type_t type(signed long a)
		{
			return mtl::types::type_t::signed_long_t;
		}

		type_t type(unsigned long long a)
		{
			return mtl::types::type_t::unsigned_long_long_t;
		}

		type_t type(signed long long a)
		{
			return mtl::types::type_t::signed_long_long_t;
		}

		type_t type(float a)
		{
			return mtl::types::type_t::float_t;
		}

		type_t type(double a)
		{
			return mtl::types::type_t::double_t;
		}

		type_t type(long double a)
		{
			return mtl::types::type_t::long_double_t;
		}

		type_t type(char a)
		{
			return mtl::types::type_t::char_t;
		}
		// 类型
		typedef unsigned int uint_t;
		typedef signed int sint_t;
		typedef unsigned int *puint_t;
		typedef signed int *psint_t;
		typedef int default_t;
		typedef int *pdefault_t;

		typedef unsigned short ushort_t;
		typedef signed short sshort_t;
		typedef unsigned short *pushort_t;
		typedef signed short *psshort_t;
		typedef short small_t;
		typedef short *psmall_t;

		typedef unsigned long ulong_t;
		typedef signed long slong_t;
		typedef unsigned long *pulong_t;
		typedef signed long *pslong_t;
		typedef long big_t;
		typedef long *pbig_t;

		typedef unsigned long long ulong_long_t;
		typedef signed long long slong_long_t;
		typedef unsigned long long *pulong_long_t;
		typedef signed long long *pslong_long_long_t;
		typedef long long biggest_long_t;
		typedef long long biggest_long_long_t;

		typedef float decimal_t;
		typedef float *pdecimal_t;

		typedef double big_decimal_t;
		typedef double *pbig_decimal_t;

		typedef long double biggest_decimal_t;
		typedef long double *pbiggest_decimal_t;

		typedef unsigned char uchar_t;
		typedef signed char schar_t;
		typedef char charecter_t;
		typedef char *str_t;
		typedef char *pchar_t;
		typedef char16_t unicode16_t;
		typedef char32_t unicode32_t;
// c++20后定义了char8_t,使用UTF-8
#if defined(__cplusplus) && __cplusplus >= 202002L
		typedef char8_t unicode8_t;
#endif
	}
	inline namespace number
	{
		const double pi = 3.141592653589793;
		const double tua = 6.283185307179586;
		const double e = 2.718281828459045;
		const double phi = 1.618033988749894;
	}

	inline namespace math
	{
		// 正方形面积
		int squareArea(int a)
		{
			return a * a;
		}
		// 正方形周长
		int squarePerimeter(int a)
		{
			return a * 4;
		}
		// 矩形面积
		int rectangleArea(int a, int b)
		{
			return a * b;
		}
		// 矩形周长
		int rectanglePerimeter(int a, int b)
		{
			return (a + b) * 2;
		}
		// BMI
		int BMI(int high, int kg)
		{
			return (kg / high) * (kg / high);
		}
		// 圆的面积
		double circularArea(int r)
		{
			return pi * r * r;
		}
		// 圆的周长
		double circlePerimeter(int r)
		{
			return 2 * pi * r;
		}
		// 三角形面积
		int triangleArea(int a, int b)
		{
			return a * b / 2;
		}
		// 三角形周长
		int trianglePerimeter(int a, int b, int c)
		{
			return a + b + c;
		}
		// 梯形面积
		int trapezoidalArea(int a, int b, int c)
		{
			return (a + b) * c / 2;
		}
		// 梯形周长
		int trapezoidalPerimeter(int a, int b, int c, int d)
		{
			return a + b + c + d;
		}
		// 加法
		int add(int a, int b)
		{
			return a + b;
		}
		// 减法
		int sub(int a, int b)
		{
			return a - b;
		}
		// 乘法
		int mul(int a, int b)
		{
			return a * b;
		}
		// 除法
		int div(int a, int b)
		{
			return a / b;
		}
		// 取余
		int mod(int a, int b)
		{
			return a % b;
		}
		long long pow(long long a, long long b)
		{
			if (b < 0)
			{
				// 处理负指数的情况,根据定义,a 的 -b 次幂等于 1 / a 的 b 次幂
				a = 1 / a;
				b = -b;
			}

			long long result = 1;
			while (b > 0)
			{
				// 如果 b 是奇数,那么 a 的 b 次幂等于 a 的 (b / 2) 次幂的平方
				// 如果 b 是偶数,那么 a 的 b 次幂等于 a 的 (b / 2) 次幂的平方再乘以 a
				if (b % 2 == 1)
				{
					result *= a;
				}
				a *= a; // a 的平方
				b /= 2; // b 除以 2
			}
			return result;
		}

		// 斐波那契数列
		int fib(int n)
		{
			if (n == 1 || n == 2)
			{
				return 1;
			}
			return fib(n - 1) + fib(n - 2);
		}
		// 最大公约数
		int gcd(int a, int b)
		{
			while (b != 0)
			{
				int t = b;
				b = a % b;
				a = t;
			}
			return a;
		}
		// 最小公倍数
		int lcm(int a, int b)
		{
			return a * b / gcd(a, b);
		}
		// 绝对值
		int abs(int n)
		{
			return n < 0 ? -n : n;
		}
		// 阶乘
		int factorial(int n)
		{
			int result = 1;
			for (int i = 1; i <= n; i++)
			{
				result *= i;
			}
			return result;
		}

	}
	inline namespace charecter
	{
		// 判断是否为字母
		bool isAlpha(char c)
		{
			return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
		}
		// 判断是否为数字
		bool isDigit(char c)
		{
			return c >= '0' && c <= '9';
		}
		// 判断是否为字母或数字
		bool isAlnum(char c)
		{
			return isAlpha(c) || isDigit(c);
		}
		// 判断是否为空格
		bool isSpace(char c)
		{
			return c == ' ' || c == '\t' || c == '\n' || c == '\r';
		}
		// 判断是否为小写字母
		bool isLower(char c)
		{
			return c >= 'a' && c <= 'z';
		}
		// 判断是否为大写字母
		bool isUpper(char c)
		{
			return c >= 'A' && c <= 'Z';
		}
		// 判断是否为字母
		bool isLetter(char c)
		{
			return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
		}
		// 将字符转换为ASCII码
		int toAscii(char c)
		{
			return int(c);
		}
		// 将字符转换为小写字母
		char toLower(char c)
		{
			return isUpper(c) ? (c - 'A' + 'a') : c;
		}
		// 将字符转换为大写字母
		char toUpper(char c)
		{
			return isLower(c) ? (c - 'a' + 'A') : c;
		}
		// 将ASCII码转换为字符
		char toChar(int c)
		{
			return char(c);
		}
	}
	inline namespace algorithm
	{
		// 冒泡排序
		void bubbleSort(int *arr, int n)
		{
			for (int i = 0; i < n - 1; i++)
			{
				for (int j = 0; j < n - i - 1; j++)
				{
					if (arr[j] > arr[j + 1])
					{
						int temp = arr[j];
						arr[j] = arr[j + 1];
						arr[j + 1] = temp;
					}
				}
			}
		}
		// 选择排序
		void selectionSort(int *arr, int n)
		{
			for (int i = 0; i < n - 1; i++)
			{
				int minIndex = i;
				for (int j = i + 1; j < n; j++)
				{
					if (arr[j] < arr[minIndex])
					{
						minIndex = j;
					}
				}
				if (minIndex != i)
				{
					int temp = arr[i];
					arr[i] = arr[minIndex];
					arr[minIndex] = temp;
				}
			}
		}
		// 插入排序
		void insertionSort(int *arr, int n)
		{
			for (int i = 1; i < n; i++)
			{
				int key = arr[i];
				int j = i - 1;
				while (j >= 0 && arr[j] > key)
				{
					arr[j + 1] = arr[j];
					j--;
				}
				arr[j + 1] = key;
			}
		}
		// 快速排序
		void quickSort(int *arr, int low, int high)
		{
			if (low < high)
			{
				int pivot = arr[low];
				int i = low, j = high;
				while (i < j)
				{
					while (i < j && arr[j] >= pivot)
						j--;
					if (i < j)
						arr[i++] = arr[j];
					while (i < j && arr[i] < pivot)
						i++;
					if (i < j)
						arr[j--] = arr[i];
				}
				arr[i] = pivot;
				quickSort(arr, low, i - 1);
				quickSort(arr, i + 1, high);
			}
			return;
		}
		void heapify(int *arr, int n, int i);
		// 堆排序
		void heapSort(int *arr, int n)
		{
			for (int i = n / 2 - 1; i >= 0; i--)
			{
				heapify(arr, n, i);
			}
			for (int i = n - 1; i > 0; i--)
			{
				int temp = arr[0];
				arr[0] = arr[i];
				arr[i] = temp;
				heapify(arr, i, 0);
				return;
			}
		}
		void heapify(int *arr, int n, int i)
		{
			int largest = i;
			int left = 2 * i + 1;
			int right = 2 * i + 2;
			if (left < n && arr[left] > arr[largest])
				largest = left;
			if (right < n && arr[right] > arr[largest])
				largest = right;
			if (largest != i)
			{
				int temp = arr[i];
				arr[i] = arr[largest];
				arr[largest] = temp;
				heapify(arr, n, largest);
			}
		}
		// 二分法
		int binary_search(int arr[], int l, int r, int x)
		{
			while (l <= r)
			{
				int mid = l + (r - l) / 2; // 预防整数溢出
				if (x > arr[mid])
				{
					l = mid + 1;
				}
				else if (x < arr[mid])
				{
					r = mid - 1;
				}
				else
				{
					return mid + 1; // 找到元素,返回位置加一
				}
			}
			return -1; // 未找到元素,返回-1
		}
		// 线性查找
		int linear_search(int arr[], int n, int x)
		{
			for (int i = 0; i < n; i++)
			{
				if (arr[i] == x)
				{
					return i;
				}
			}
			return -1;
		}
		// 倒序
		void reverse(int arr[], int n)
		{
			for (int i = 0; i < n / 2; i++)
			{
				int temp = arr[i];
				arr[i] = arr[n - i - 1];
				arr[n - i - 1] = temp;
			}
		}

		// 判断所有参数是否都为真
		bool all(int first, ...)
		{
			va_list args;
			va_start(args, first);
			int arg = first;
			while (true)
			{
				arg = va_arg(args, int);
				if (!arg)
				{
					va_end(args);
					return false;
				}
				if (arg == int(false))
				{
					va_end(args);
					return true;
				}
			}
		}

		// 判断所有参数是否都为假
		bool none(int first, ...)
		{
			va_list args;
			va_start(args, first);
			int arg = first;
			while (true)
			{
				arg = va_arg(args, int);
				if (arg)
				{
					va_end(args);
					return false;
				}
				if (arg == int(true))
				{
					va_end(args);
					return true;
				}
			}
		}
		// 奇数
		bool odd(int n)
		{
			return n & 1;
		}
		// 偶数
		bool even(int n)
		{
			return !(n & 1);
		}
		// 转换为格雷码
		int toGray(int n)
		{
			return n ^ (n >> 1);
		}
		// 格雷码转换回二进制码
		int GreycodetoBinary(int n)
		{
			int binary = 0;
			int i = 0;
			while (n > 0)
			{
				binary += (n & 1) << i;
				n >>= 1;
				i++;
			}
			return binary;
		}
		// 转二进制
		int toBin(int n)
		{
			int binary = 0;
			while (n > 0)
			{
				binary = (n & 1) + binary * 10;
				n >>= 1;
			}
			return binary;
		}
		// 转八进制
		int toOct(int n)
		{
			int octal = 0;
			int i = 0;
			while (n > 0)
			{
				octal = (n & 7) + octal * 10;
				n >>= 3;
				i++;
			}
			return octal;
		}
		// 转十六进制
		int toHex(int n)
		{
			int hex = 0;
			int i = 0;
			while (n > 0)
			{
				hex = (n & 15) + hex * 10;
				n >>= 4;
				i++;
			}
			return hex;
		}
		int *prefix_sum(int arr[], int n)
		{
			int *sun = (int *)malloc(sizeof(int) * (n + 1));
			for (int i = 0; i < n; i++)
			{
				sun[i + 1] = sun[i] + arr[i];
			}
			sun[0] = 0; // 初始化第一个元素为0
			return sun;
		}
		// 区间和
		int *range_sum(int arr[], int n)
		{
			int *sun = new int[n + 1];
			for (int i = 0; i < n; i++)
			{
				sun[i + 1] = sun[i] + arr[i];
			}
			return sun;
		}
		// 前缀和(二维数组)
		// 计算二维数组的前缀和
		int **prefix_sum(int **arr, int n)
		{
			int **sun = (int **)0;
			for (int i = 0; i < n; i++)
			{
				sun[i + 1] = (int *)malloc(sizeof(int) * (n + 1));
				for (int j = 0; j < n; j++)
				{
					sun[i + 1][j + 1] = sun[i][j + 1] + sun[i + 1][j] + arr[i][j] - sun[i][j];
					if (i == 0 && j == 0)
					{
						sun[i + 1][j + 1] = arr[i][j];
					}
				}
			}
			sun[0][0] = 0; // 初始化左上角为0
			return sun;
		}
		// 区间和(二维数组)
		int **range_sum(int **arr, int n)
		{
			int **sun = new int *[n + 1];
			for (int i = 0; i < n; i++)
			{
				sun[i + 1] = new int[n + 1];
				for (int j = 0; j < n; j++)
				{
					sun[i + 1][j + 1] = sun[i][j + 1] + sun[i + 1][j] + arr[i][j] - sun[i][j];
					if (i == 0 && j == 0)
					{
						sun[i + 1][j + 1] = arr[i][j];
					}
					if (i == 0 && j == 0)
					{
						sun[i + 1][j + 1] = arr[i][j];
					}
				}
			}
			return sun;
		}

		// 二叉树
		template <typename T>
		struct BinaryTree
		{
			T data;
			BinaryTree *left;
			BinaryTree *right;
			BinaryTree(T data) : data(data), left(nullptr), right(nullptr) {}
		};
		// 树
		template <typename T>
		struct Tree
		{
			T data;
			Tree *clilds[100];
			Tree(T data) : data(data) {}
		};
		// 图
		template <typename T>
		struct Graph
		{
			T data;
			Graph *edges[100];
			Graph(T data) : data(data) {}
		};
	}
	// 大字
	inline namespace big_words
	{
		void A()
		{
			mtl::print(R"(
          AAAAA
         AAA AAA
        AAA   AAA
       AAA     AAA
      AAA       AAA
     AAAAAAAAAAAAAAA
    AAA           AAA
   AAA             AAA
  AAA               AAA
 AAA                 AAA
)");
		}
		void B()
		{
			mtl::print(R"(
BBBBBBBBBBBBBBB
BBB           BBB
BBB            BBB
BBB           BBB
BBBBBBBBBBBBBBBB
BBB           BBB
BBB            BBB
BBB             BBB
BBB            BBB
BBBBBBBBBBBBBBBB
)");
		}
		void C()
		{
			mtl::print(R"(
    CCCCCCCCCCCCCCC
   CCCCCCCCCCCCCCCCC
  CCCC
 CCCC
CCCC
CCCC
 CCCC
  CCCC
   CCCCCCCCCCCCCCCCCC
    CCCCCCCCCCCCCCCC
)");
		}
		void D()
		{
			mtl::print(R"(
DDDDDDDDDDDDDDDDDDD
DDD              DDD
DDD                DDD
DDD                 DDD
DDD                 DDD
DDD                 DDD
DDD                 DDD
DDD                 DDD
DDD               DDD
DDDDDDDDDDDDDDDDDDDD
)");
		}
		void E()
		{
			mtl::print(R"(
EEEEEEEEEEEEEEEEEEEE
EEE
EEE
EEE
EEE
EEEEEEEEEEEEEEEEEEEE
EEE
EEE
EEE
EEEEEEEEEEEEEEEEEEEE
)");
		}
		void F()
		{
			mtl::print(R"(
FFFFFFFFFFFFFFFFFFFF
FFF
FFF
FFF
FFF
FFFFFFFFFFFFFFFFFFFF
FFF
FFF
FFF
FFF
)");
		}
		void G()
		{
			mtl::print(R"(
    GGGGGGGGGGGGGG
   GGG
  GGG
 GGG
GGG
GGG
 GGG         GGGGGGGGG
  GGG              GGG
   GGG            GGG
    GGGGGGGGGGGGGGGG
)");
		}
		void H()
		{
			mtl::print(R"(
HHH            HHH
HHH            HHH
HHH            HHH
HHH            HHH
HHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHHHH
HHH            HHH
HHH            HHH
HHH            HHH
HHH            HHH
)");
		}
		void I()
		{
			mtl::print(R"(
IIIIIIIIIIIIIIIIIII
        III
        III
        III
        III
        III
        III
        III
        III
IIIIIIIIIIIIIIIIIII
)");
		}
		void J()
		{
			mtl::print(R"(
 JJJJJJJJJJJJJJJJJJJ
         JJJ
         JJJ
         JJJ
         JJJ
         JJJ
         JJJ
JJJ      JJJ
 JJJ    JJJ
   JJJJJ
)");
		}
		void K()
		{
			mtl::print(R"(
KKK          KKK
KKK        KKK
KKK      KKK
KKK    KKK
KKKKKKKK
KKK    KKK
KKK      KKK
KKK        KKK
KKK         KKK
KKK          KKK
)");
		}

		void L()
		{
			mtl::print(R"(
LLL
LLL
LLL
LLL
LLL
LLL
LLL
LLL
LLLLLLLLLLLLLLL
LLLLLLLLLLLLLLL
)");
		}
		void N()
		{
			mtl::print(R"(
NNN        NNN
NNNNN      NNN
NNN NNN    NNN
NNN  NNN   NNN
NNN   NNN  NNN
NNN    NNN NNN 
NNN     NNNNNN
NNN      NNNNN
NNN        NNN
NNN        NNN
)");
		}
		void M()
		{
			mtl::print(R"(
MMM               MMM
MMMMM            MMMM
MMM MMM         MMMMM
MMM  MMM       MMMMMM
MMM   MMM     MMM MMM
MMM    MMM   MMM  MMM
MMM     MMM MMM   MMM
MMM      MMMMM    MMM
MMM       MMM     MMM
MMM       MMM     MMM
)");
		}

		void O()
		{
			mtl::print(R"(
      OOOOOOO
    OOO     OOO
  OOO         OOO
 OO             OO
 OO             OO
  OOO         OOO
    OOO     OOO
      OOOOOOO     
)");
		}
		void P()
		{
			mtl::print(R"(
PPPPPPPPPPPPPPPP
PPP            PPP
PPP             PPP   
PPP            PPP
PPP           PPP
PPPPPPPPPPPPPPP
PPP
PPP
PPP
PPP
)");
		}
		void Q()
		{
			mtl::print(R"(
      QQQQQQQ
    QQQ     QQQ
  QQQ        QQQ
QQQ            QQQ
QQQ            QQQ
  QQQ   QQQ   QQQ
    QQQ   QQQQQ
      QQQQQQQQ   
            QQQ
)");
		}
		void R()
		{
			mtl::print(R"(
RRRRRRRRRRR
RRR       RRR
RRR        RRR
RRR       RRR
RRRRRRRRRRRR
RRRRRR
RRR RRR
RRR   RRR
RRR     RRR
RRR       RRR
)");
		}
		void S()
		{
			mtl::print(R"(
    SSSSSSSSSSSSSSS
 SSS
SSS
  SSS
   SSS
    SSSSSSSSSSSSSSSS
                  SSS
                   SSS
                  SSS
    SSSSSSSSSSSSSSSSS
)");
		}
		void T()
		{
			mtl::print(R"(
TTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTT
        TTT
        TTT
        TTT
        TTT
        TTT
        TTT
        TTT
        TTT
)");
		}
		void U()
		{
			mtl::print(R"(
UUU                UUU
UUU                UUU
UUU                UUU
UUU                UUU
UUU                UUU
UUU                UUU
 UUU              UUU
  UUU            UUU
   UUUUUUUUUUUUUUUU
    UUUUUUUUUUUUUU
)");
		}
		void V()
		{
			mtl::print(R"(
VVV                 VVV
 VVV               VVV
  VVV             VVV
   VVV           VVV
    VVV         VVV 
     VVV       VVV
      VVV     VVV
       VVV   VVV
        VVV VVV
         VVVVV
)");
		}
		void W()
		{
			mtl::print(R"(
WWW       WWWWW       WWW
WWW       WWWWW       WWW
 WWW     WWW WWW     WWW
 WWW     WWW WWW     WWW
  WWW   WWW   WWW   WWW
  WWW   WWW   WWW   WWW
   WWW WWW     WWW WWW
   WWW WWW     WWW WWW
    WWWWW       WWWWW
    WWWWW       WWWWW
)");
		}
		void X()
		{
			mtl::print(R"(
XXX               XXX
  XXX           XXX
    XXX       XXX
      XXX   XXX
        XXXXX
        XXXXXX
      XXX    XXX
    XXX       XXX
  XXX           XXX
XXX               XXX
)");
		}
		void Y()
		{
			mtl::print(R"(
YYY             YYY
  YYY         YYY
    YYY     YYY
      YYY YYY
       YYYYY
        YYY
        YYY
        YYY
        YYY
        YYY
)");
		}
		void Z()
		{
			mtl::print(R"(
ZZZZZZZZZZZZZZZZZZZZ
                 ZZZ
               ZZZ
             ZZZ
           ZZZ
         ZZZ
       ZZZ
     ZZZ
   ZZZ
ZZZZZZZZZZZZZZZZZZZZ
)");
		}
		void one()
		{
			mtl::print(R"(
        1111111
            111
            111
            111
            111
            111
            111
            111
            111
            111
)");
		}
		void two()
		{
			mtl::print(R"(
22222222222222222222
                 222
                 222
                 222
22222222222222222222
222
222
222
222
22222222222222222222
)");
		}
		void three()
		{
			mtl::print(R"(
33333333333333333333
                 333
                 333
                 333
33333333333333333333
                 333
                 333
                 333
                 333
33333333333333333333
)");
		}
		void four()
		{
			mtl::print(R"(
444           444
444           444
444           444
444           444
4444444444444444444
              444
              444
              444
              444
              444
)");
		}
		void five()
		{
			mtl::print(R"(
5555555555555555555
555
555
555
5555555555555555555
                555
                555
                555
                555
5555555555555555555
)");
		}
		void six()
		{
			mtl::print(R"(
6666666666666666666
666                
666
666
6666666666666666666
666             666
666             666
666             666
666             666
6666666666666666666
)");
		}
		void seven()
		{
			mtl::print(R"(
77777777777777777777
                 777
                 777
                 777
                 777
                 777
                 777
                 777
                 777
                 777
)");
		}
		void eight()
		{
			mtl::print(R"(
88888888888888888888
888              888
888              888
888              888
88888888888888888888
888              888
888              888
888              888
888              888
88888888888888888888
)");
		}
		void nine()
		{
			mtl::print(R"(
99999999999999999999
999              999
999              999
999              999
99999999999999999999
                 999
                 999
                 999
                 999
99999999999999999999
)");
		}
		void zero()
		{
			mtl::print(R"(
00000000000000000000
000              000
000              000
000              000
000              000
000              000
000              000
000              000
000              000
00000000000000000000
)");
		}
	}
	// 信息
	inline namespace informations
	{
		/*
		// ????????????????????
		void Mental_state()
		{
			mtl::println(R"(
???? ??????????
   ?????????????
????????????????
????????????????
???????????????
?????????
??????????????
?????????????????
?????????????????)");
		}
		*/
		// 版本
		void version()
		{
			mtl::println(R"(
           MMM               MMM     TTTTTTTTTTTTTTTTTT    LLL
          MMMMM           MMMMM     TTTTTTTTTTTTTTTTTT    LLL
         MMMMMMM       MMM MMM            TTT            LLL
        MMM   MMM   MMM   MMM            TTT            LLL
       MMM     MMMMM     MMM            TTT            LLL
      MMM      MMM      MMM            TTT            LLL
     MMM      MMM      MMM            TTT            LLL
    MMM      MMM      MMM            TTT            LLL
   MMM      MMM      MMM            TTT            LLLLLLLLLLLLLL
  MMM      MMM      MMM            TTT            LLLLLLLLLLLLLL
)");
			mtl::println(R"(
MTL Version: 1.0.2
data: 2024/5/2
)");
		}
// 帮助
#ifndef _WIN32
		void help()
		{
			mtl::println("Please turn on README.md\nhelp now?\n\npress h, else press other key.");
			if (_getch() == 'h')
			{
				mtl::println("Functions:");
				mtl::println("  print         output");
				mtl::println("  println       output and end line");
				mtl::println("  adds          find the sum of n numbers");
				mtl::println("  max           maximum");
				mtl::println("  min           minimum");
				mtl::println("  maxs          Multiple numbers are maximized");
				mtl::println("  mins          Multiple numbers are minimized");
				mtl::println("  gaussian_sum  Gauss sums");
				mtl::println("  isPalindromic Determine whether it is a palindrome");
				mtl::_pass();
				mtl::println("Macros:");
				mtl::println("  noerr         noexcept");
				mtl::println("  noerror       noexcept");
				mtl::println("  lower_list    \"abcdefghijklmnopqrstuvwxyz\"");
				mtl::println("  upper_list    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"");
				mtl::println("  symbol_list   \"!@#$%^&*()_+-=[]\\{}|;':\",./<>?\"");
				mtl::println("  ascii_list    \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-=[]\\{}|;':\",./<>?\"");
				mtl::println("  ascii_len     94");
				mtl::println("  all_ascii     128");
				mtl::println("  int_max       2147483647");
				mtl::println("  int_min       -2147483648");
				mtl::println("  short_max     32767");
				mtl::println("  short_min     -32768");
				mtl::println("  long_max      9223372036854775807");
				mtl::println("  long_min      -9223372036854775808");
				mtl::println("  long_long_max 9223372036854775807");
				mtl::println("  long_long_min -9223372036854775808");
				mtl::println("  float_max     3.40282347e+38");
				mtl::println("  float_min     1.17549435e-38");
				mtl::println("  double_max    1.7976931348623157e+308");
				mtl::println("  double_min    2.2250738585072014e-308");
				mtl::println("  bool_true     true");
				mtl::println("  bool_false    false");
				mtl::println("  null          null");
				mtl::println("  nullstr       \"\"");
				mtl::println("  flaot_precision  6");
				mtl::println("  double_precision 15");
				mtl::println("  int_precision    10");
				mtl::println("  short_precision  5");
				mtl::println("  long_precision   20");
				mtl::println("  long_long_precision  20");
				mtl::_pass();
				mtl::println("Namespace:");
				mtl::println("  types");
				mtl::println("    type        Type judgment");
				mtl::println("    types       some types");
				mtl::_pass();
				mtl::println("  number        some numbers");
				mtl::println("    pi          3.1415926535897932384626433..");
				mtl::println("    e           2.718281828459045235360287..");
				mtl::println("    phi         1.618033988749894848204586..");
				mtl::println("    tau         6.283185307179586476925286..");
				mtl::_pass();
				mtl::println("  math                    some math constants");
				mtl::println("    squareArea            square area of a circle");
				mtl::println("    squarePerimeter       square perimeter of a circle");
				mtl::println("    rectangleArea         rectangle area of a circle");
				mtl::println("    rectanglePerimeter    rectangle perimeter of a circle");
				mtl::println("    BIM                   BMI");
				mtl::println("    circleArea            circle area of a circle");
				mtl::println("    circlePerimeter       circle perimeter of a circle");
				mtl::println("    teiangleArea          teiangle area of a circle");
				mtl::println("    teianglePerimeter     teiangle perimeter of a circle");
				mtl::println("    trapezoidalArea       trapezoidal area of a circle");
				mtl::println("    trapezoidalPerimeter  trapezoidal perimeter of a circle");
				mtl::println("    add                   add two numbers");
				mtl::println("    sub                   subtract two numbers");
				mtl::println("    mul                   multiply two numbers");
				mtl::println("    div                   divide two numbers");
				mtl::println("    mod                   modulo two numbers");
				mtl::println("    pow                   raise a number to a power");
				mtl::println("    fib                   fibonacci sequence");
				mtl::println("    gcd                   greatest common divisor");
				mtl::println("    lcm                   least common multiple");
				mtl::_pass();
				mtl::println("  algorithm");
				mtl::println("    bubbleSort             bubble sort");
				mtl::println("    selectionSort          selection sort");
				mtl::println("    insertionSort          insertion sort");
				mtl::println("    quickSort              quick sort");
				mtl::println("    heapSort               heap sort");
				mtl::println("    binarySearch           binary search");
				mtl::println("    linear_sear            linear search");
				mtl::println("    reverse                reverse");
				mtl::println("    all                    all true");
				mtl::println("    none                   all false");
				mtl::_pass();
				mtl::println("  charecter			    charecter");
				mtl::println("    isAlpha               is alpha");
				mtl::println("    isDight               is dight");
				mtl::println("    isAlNum               is alpha num");
				mtl::println("    isSpace               is space");
				mtl::println("    isLower               is lower");
				mtl::println("    isUpper               is upper");
				mtl::println("    isLetter              is letter");
				mtl::println("    toAscii               to ascii");
				mtl::println("    toChar                to char");
				mtl::println("    toLower               to lower");
				mtl::println("    toUpper               to upper");
				mtl::_pass();
				mtl::println("  information             information");
				mtl::println("    version               version");
				mtl::println("    help                  help documentation");
			}
		}
#endif
	}
}

mtl_def.h

#pragma once

/
//     宏定义               //
/

#define noerr noexcept
#define noerror noexcept
#define lower_list "abcdefghijklmnopqrstuvwxyz"
#define upper_list "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define number_list "0123456789"
#define symbol_list "!@#$%^&*()_+-=[]\\{}|;':\",./<>?"
#define ascii_list "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-=[]\\{}|;':\",./<>?"
#define ascii_len (94)
#define all_ascii_len (128)
#define int_max (2147483647)
#define int_min (-2147483648)
#define short_max (32767)
#define short_min (-32768)
#define long_max (9223372036854775807)
#define long_min (-9223372036854775808)
#define long_long_max (9223372036854775807)
#define long_long_min (-9223372036854775808)
#define double_max (1.7976931348623158e+308)
#define double_min (-1.7976931348623158e+308)
#define float_max (3.402823466e+38)
#define float_min (-3.402823466e+38)
#define double_max (1.7976931348623158e+308)
#define double_min (-1.7976931348623158e+308)
#define bool_true (1)
#define bool_false (0)
#define null (0)
#define null_str ("")
#define float_precision (6)
#define double_precision (15)
#define int_precision (10)
#define short_precision (5)
#define long_precision (20)
#define long_long_precision (20)
#define char_precision (1)


//       工具                     //
///

#define useprint 1

//
//       一堆函数声明        //
/

namespace mtl
{
    // print函数声明
    void print(const char *format, ...);
    // println函数声明
    void println(const char *format, ...);
    // pass函数声明
    void pass();
    // adds函数声明
    template <typename T>
    double adds(const T &init, const T &value, ...);
    // max函数声明
    template <typename T1, typename T2>
    double max(T1, T2);
    // min函数声明
    template <typename T1, typename T2>
    double min(T1, T2);
    // maxs函数声明
    template <typename T, typename... Args>
    double maxs(T, Args...);
    // mins函数声明
    template <typename T, typename... Args>
    double mins(T, Args...);
    // gaussian_sum函数声明
    long gaussian_sum(int);
    // isPalindromic函数声明
    bool isPalindromic(int);
    bool isPalindromic(const char *);
    inline namespace types
    {
        // 类型类
        enum type_t
        {
            unsigned_int_t = 0,
            signed_int_t,
            unsigned_short_t,
            signed_short_t,
            unsigned_long_t,
            signed_long_t,
            unsigned_long_long_t,
            signed_long_long_t,
            float_t,
            double_t,
            long_double_t,
            char_t
        };
        // type函数声明
        type_t type(unsigned int);
        type_t type(signed int);
        type_t type(unsigned short);
        type_t type(signed short);
        type_t type(unsigned long);
        type_t type(signed long);
        type_t type(unsigned long long);
        type_t type(signed long long);
        type_t type(float);
        type_t type(double);
        type_t type(long double);
        type_t type(char);
    }

    inline namespace math
    {
        // squareArea函数声明
        int squareArea(int a);
        // squarePerimeter函数声明
        int squarePerimeter(int a);
        // rectangleArea函数声明
        int rectangleArea(int a, int b);
        // rectanglePerimeter函数声明
        int rectanglePerimeter(int a, int b);
        // BIM函数声明
        int BMI(int high, int kg);
        // circularArea函数声明
        double circularArea(int r);
        // circularPerimeter函数声明
        double circularPerimeter(int r);
        // triangleArea函数声明
        int triangleArea(int a, int b);
        // trianglePerimeter函数声明
        int trianglePerimeter(int a, int b, int c);
        // trapezoidalArea函数声明
        int trapezoidalArea(int a, int b, int c);
        // trapezoidalPerimeter函数声明
        int trapezoidalPerimeter(int a, int b, int c, int d);
        // add函数声明
        int add(int a, int b);
        // sub函数声明
        int sub(int a, int b);
        // mul函数声明
        int mul(int a, int b);
        // div函数声明
        int div(int a, int b);
        // mod函数声明
        int mod(int a, int b);
        // pow函数声明
        long long pow(long long a, long long b);
        // fib函数声明
        int fib(int n);
        // gcd函数声明
        int gcd(int a, int b);
        // lcm函数声明
        int lcm(int a, int b);
    }
    inline namespace charecter
    {
        // isAlpha函数声明
        bool isAlpha(char c);
        // isDigit函数声明
        bool isDigit(char c);
        // isAlnum函数声明
        bool isAlnum(char c);
        // isSpace函数声明
        bool isSpace(char c);
        // isLower函数声明
        bool isLower(char c);
        // isUpper函数声明
        bool isUpper(char c);
        // isLetter函数声明
        bool isLetter(char c);
        // toAscii函数声明
        int toAscii(char c);
        // toLower函数声明
        char toLower(char c);
        // toUpper函数声明
        char toUpper(char c);
        // toChar函数声明
        char toChar(int c);
    }
    inline namespace algorithm
    {
        // bubbleSort函数声明
        void bubbleSort(int *arr, int n);
        // selectionSort函数声明
        void selectionSort(int *arr, int n);
        // insertionSort函数声明
        void insertionSort(int *arr, int n);
        // quickSort函数声明
        void quickSort(int *arr, int low, int high);
        // heapSort函数声明
        void heapSort(int *arr, int n);
        // binary_search函数声明
        int binary_search(int arr[], int l, int r, int x);
        // linear_search函数声明
        int linear_search(int arr[], int n, int x);
        // reverse函数声明
        void reverse(int arr[], int n);
        // all函数声明
        bool all(int first, ...);
        // none函数声明
        bool none(int first, ...);
        // odd函数声明
        bool odd(int n);
        // even函数声明
        bool even(int n);
        // toGray函数声明
        int toGray(int n);
        // GreycodetoBinary函数声明
        int GreycodetoBinary(int n);
        // toBin函数声明
        int toBin(int n);
        // toOct函数声明
        int toOct(int n);
        // toHex函数声明
        int toHex(int n);
    }
    inline namespace big_words
    {
        // A函数声明
        void A();
        // B函数声明
        void B();
        // C函数声明
        void C();
        // D函数声明
        void D();
        // E函数声明
        void E();
        // F函数声明
        void F();
        // G函数声明
        void G();
        // H函数声明
        void H();
        // I函数声明
        void I();
        // J函数声明
        void J();
        // K函数声明
        void K();
        // L函数声明
        void L();
        // M函数声明
        void M();
        // N函数声明
        void N();
        // O函数声明
        void O();
        // P函数声明
        void P();
        // Q函数声明
        void Q();
        // R函数声明
        void R();
        // S函数声明
        void S();
        // T函数声明
        void T();
        // U函数声明
        void U();
        // V函数声明
        void V();
        // W函数声明
        void W();
        // X函数声明
        void X();
        // Y函数声明
        void Y();
        // Z函数声明
        void Z();
        // one函数声明
        void one();
        // two函数声明
        void two();
        // three函数声明
        void three();
        // four函数声明
        void four();
        // five函数声明
        void five();
        // six函数声明
        void six();
        // seven函数声明
        void seven();
        // eight函数声明
        void eight();
        // nine函数声明
        void nine();
        // ten函数声明
        void ten();
        // zero函数声明
        void zero();
    }
    inline namespace informations
    {
        // version函数声明
        void version();
        // help函数声明
        void help();
    }
}

main.cpp

#include "mtl.h"

int main()
{
	mtl::informations::version(); // 输出版本信息
	return 0;
}

下载:mtl.zip官方版下载丨最新版下载丨绿色版下载丨APP下载-123云盘

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值