问题标题: 急需代码

0
1

1
已采纳
吴庞茂旭
吴庞茂旭
资深光能
资深光能

写游戏吗?

安排!

//exam_tree.h
#include "windows.h";
#include<assert.h>    //设定插入点
#include <ctype.h>     //字符处理
#include <errno.h>     //定义错误码
#include <float.h>     //浮点数处理
#include <fstream>   //文件输入/输出
#include <iomanip>   //参数化输入/输出
#include<iostream>   //数据流输入/输出
#include<limits.h>    //定义各种数据类型最值常量
#include<locale.h>    //定义本地化函数
#include <math.h>     //定义数学函数
#include <stdio.h>    //定义输入/输出函数
#include<stdlib.h>    //定义杂项函数及内存分配函数
#include <string.h>    //字符串处理
#include<strstream>   //基于数组的输入/输出
#include<time.h>     //定义关于时间的函数
#include <wchar.h>    //宽字符处理及输入/输出
#include <wctype.h>    //宽字符分类
#include <algorithm>    //STL通用算法
#include <bitset>     //STL位集容器
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>     //复数类
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>      //STL双端队列容器
#include <exception>    //异常处理类
#include <fstream>
#include <functional>   //STL定义运算函数(代替运算符)
#include <limits>
#include <list>      //STL线性列表容器
#include <map>       //STL 映射容器
#include <iomanip>
#include <ios>      //基本输入/输出支持
#include<iosfwd>     //输入/输出系统使用的前置声明
#include <iostream>
#include <istream>     //基本输入流
#include <ostream>     //基本输出流
#include <queue>      //STL队列容器
#include <set>       //STL 集合容器
#include <sstream>    //基于字符串的流
#include <stack>      //STL堆栈容器    
#include <stdexcept>    //标准异常类
#include <streambuf>   //底层输入/输出支持
#include <string>     //字符串类
#include <utility>     //STL通用模板类
#include <vector>     //STL动态数组容器
#include <cwchar>
#include <cwctype>
#include <conio.h>
using namespace std;
#define REP(i,a,b) for (int i=(a);i<=(b);i++)
#define PER(i,a,b) for (int i=(a);i>=(b);i--)
#define max(x,y) ((x)<(y)?(y):(x))
#define min(y,x) ((x)<(y)?(x):(y))
#define MEM(a,b) memset(a,(b),sizeof(a))
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)//判断这个键是否按下
#define KEY_UP(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 0 : 1)//判断这个键是否弹起
#define KEY_EVERY(lpkeyState) GetKeyboardState(lpKeyState)//获得所有的256个键(键盘按键、鼠标按键等等)的状态,lpKeyState是指向一个256bit的数组,存放所有键的状态。
#define KEY_NOW(nVirtKey) GetKeyState(nVirtKey)//用于判断nVirtKey的状态。用返回值的最高位表示,最高位为1表示当前键处于down的状态;最高位为0当前键处于up状态。此函数从消息队列中读取消息进行处理。
#define setcolor(x) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x)//设置颜色
#define getkey(x) GetAsyncKeyState(x)
#define GetWindow() GetForegroundWindow();//得到窗口信息
/*
鼠标左键 : MOUSE_MOVED 
鼠标右键 :MOUSE_EVENT
鼠标滚轮 : MOUSE_WHEELED
MK_CONTROL当CTRL键按下时。
MK_LBUTTON当鼠标左键按下时。
MK_MBUTTON当鼠标中键按下时。
MK_RBUTTON当鼠标右键按下时.
MK_SHIFT当SHIFT按下时。
*/
using std::cin;
using std::cout;
using std::endl;
int brand();
void GOTO(int x,int y);
int brand(){return (rand()<<16)|(rand()<<1)|(rand()&1);}
void bsrand(){srand(GetTickCount());}
void cls(){//赟刑道提供,如有侵权请联系删除。    
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = { 0, 0 };    // home for the cursor
    SetConsoleCursorPosition( hConsole, coordScreen );
}
void retr(){//退出程序 
    HWND hWnd=GetForegroundWindow();
    ShowWindow(hWnd,SW_HIDE);
    exit(0);
}
void Window_Hide(HWND hWnd){ShowWindow(hWnd,0);}//隐藏窗口
void Window_Show(HWND hWnd){ShowWindow(hWnd,1);}//显示窗口
int getmouse_y(){//获取鼠标在屏幕中x的位置 
    POINT pt; 
    GetCursorPos(&pt);
    return pt.x;
}
int getmouse_x(){//获取鼠标在屏幕中y的位置 
    POINT pt; 
    GetCursorPos(&pt);
    return pt.y;
}
void setmouse(int y,int x){SetCursorPos(x,y);}//设置鼠标在屏幕中的位置 
void click_left(){//鼠标左键点击
    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);  
    Sleep(5);//要留给某些应用的反应时间   
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); 
}
void click_right(){//鼠标右键点击
    mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);  
    Sleep(5);   
    mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);  
}
void GOTO(int x,int y){//将光标移动到屏幕中的位置
    CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
    HANDLE hConsoleOut;
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
    csbiInfo.dwCursorPosition.Y = x;
    csbiInfo.dwCursorPosition.X = y;
    SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);
}
/* 
附录1:(COLOR) 
    1   深蓝色
    2   深绿色
    3   深青色
    4   深红色
    5   深粉色
    6   黄色
    7   深白色
    8   灰色
    9   浅蓝色
    10  浅绿色
    11  浅青色
    12  浅红色
    13  浅粉色
    14  浅黄色
    15  浅白色

    背景 
    1~15        黑色
    16~31       深蓝色
    32~47       深绿色
    48~63       深青色
    64~79       深红色
    80~95       深粉色
    96~111      深黄色
    112~127     深白色
    128~143     灰色
    144~159     浅蓝色
    160~175     浅绿色
    176~191     浅青色
    192~207     浅红色
    208~223     浅粉色
    224~239     浅黄色
    240~255     浅白色

附录2(KEY NUMBER) 
    VK_LBUTTON             鼠标左键                      0x01 
    VK_RBUTTON             鼠标右键                      0x02 
    VK_CANCEL              Ctrl + Break                  0x03 
    VK_MBUTTON             鼠标中键                      0x04 

    VK_BACK                Backspace 键                   0x08 
    VK_TAB                 Tab 键                        0x09 

    VK_RETURN              回车键                        0x0D 


    VK_SHIFT               Shift 键                      0x10 
    VK_CONTROL             Ctrl 键                       0x11 
    VK_MENU                Alt 键                         0x12 
    VK_PAUSE               Pause 键                      0x13 
    VK_CAPITAL             Caps Lock 键                  0x14 

    VK_ESCAPE              Esc 键                        0x1B 

    VK_SPACE               空格键                       0x20 
    VK_PRIOR               Page Up 键                    0x21 
    VK_NEXT                Page Down 键                  0x22 
    VK_END                 End 键                        0x23 
    VK_HOME                Home 键                       0x24 
    VK_LEFT                左箭头键                      0x25 
    VK_UP                  上箭头键                      0x26 
    VK_RIGHT               右箭头键                      0x27 
    VK_DOWN                下箭头键                      0x28 
    VK_SNAPSHOT            Print Screen 键               0x2C 
    VK_Insert              Insert 键                     0x2D 
    VK_Delete              Delete 键                     0x2E 

    '0' – '9'             数字 0 - 9                    0x30 - 0x39 
    'A' – 'Z'             字母 A - Z                    0x41 - 0x5A 

    VK_LWIN                左WinKey(104键盘才有)         0x5B 
    VK_RWIN                右WinKey(104键盘才有)         0x5C 
    VK_APPS                AppsKey(104键盘才有)          0x5D 

    VK_NUMPAD0            小键盘 0 键                    0x60 
    VK_NUMPAD1            小键盘 1 键                    0x61 
    VK_NUMPAD2            小键盘 2 键                    0x62 
    VK_NUMPAD3            小键盘 3 键                    0x63 
    VK_NUMPAD4            小键盘 4 键                    0x64 
    VK_NUMPAD5            小键盘 5 键                    0x65 
    VK_NUMPAD6            小键盘 6 键                    0x66 
    VK_NUMPAD7            小键盘 7 键                    0x67 
    VK_NUMPAD8            小键盘 8 键                    0x68 
    VK_NUMPAD9            小键盘 9 键                    0x69 

    VK_F1 - VK_F24        功能键F1 – F24                0x70 - 0x87 

    VK_NUMLOCK            Num Lock 键                    0x90 
    VK_SCROLL             Scroll Lock 键                 0x91 
*/

将其保存为tree.h,然后用的时候第一行写#include "tree.h"并把这个代码写在相同文件夹下即可!

1
王文博
王文博
缔造者之神
缔造者之神

isalpha,isctype,isupper等等

王文博在2021-08-01 14:45:52追加了内容

isctype(int _C,int _Type);

isalpha(int _C);

isupper(int _C);

islower(int _C);

isdigit(int _C);

王文博在2021-08-01 14:46:39追加了内容

这是我AC那么多题目的……

王文博在2021-08-01 14:52:28追加了内容

int isalnum(int _c):检查字符是否为数字或字母;(0~9,a~z,A~Z)
int isalpha(int _c):检查字符是否为字母;(a~z, A~Z)
int iscntrl(int _c):检查字符是否为控制字符;(八进制000~037以及177的字符)
int isdigit(int _c):检查字符是否为十进制数字;(0~9)
int isgraph(int _c):检查字符是否为图形表示,依赖于使用语言的环境;0~9,a~z,A~Z,以及标点符号)
int islower(int _c):检查字符是否为小写的字母;(a~z)
int isprint(int _c):检查字符是否为可打印的;(数字、字母、标点符号、空白字符)
int ispunct(int _c):检查字符是否为标点符号;(! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ ] ^ _ ` { | } ~等)
int isspace(int _c):检查字符是否为空白字符;(TAB、换行、垂直TAB、换页、回车、空格)
int isupper(int _c):检查字符是否为大写字母;(A~Z)
int isxdigit(int _c):检查字符是否为十六进制数字;(0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f)
int tolower(int _c):转化字符为小写字母;
int toupper(int _c):转化字符为大写字母;

这些都是和字符打交道的,返回值却是int??

没关系,除最后两个以外,返回值都是0或1,可以当做bool去看。

最后两个就是int和char都可以了,int存的是它的ASCII码,转换为char就是字符。其余形式都不可以。

望采纳!(头文件:#include "ctype.h")

0
0
0
我要回答