代码自动机(专攻ACwing限时题)

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int tot=0;
void an(int a)
{
    keybd_event(a,0,0,0);
    keybd_event(a,0,KEYEVENTF_KEYUP,0);
}
void dx1()
{
    keybd_event(16,0,0,0);
}
void dx2()
{
    keybd_event(16,0,KEYEVENTF_KEYUP,0);
}
bool f=1;
int main()
{
    freopen("b.in","r",stdin);
    char t;
    for(int i=5;i>=0;i--)
    {
        cout<<i<<endl;
        Sleep(1000);
    }
    while(1)
    {
        keybd_event(46,0,0,0);
        keybd_event(46,0,KEYEVENTF_KEYUP,0);
        system("cls");
        t=getchar();
        if(t==10)
        {
            an(13);
            for(int i=1;i<=300;i++)
            {
                keybd_event(46,0,0,0);
                keybd_event(46,0,KEYEVENTF_KEYUP,0);   
            }
            f=0;
            continue;
        }
        else if(t==' '&&f==1)
        {
            an(32);
            f=0;
            continue;
        }
        f=1;
        if(t>='a'&&t<='z')
            an(int(t)-32);
        else if(t>='A'&&t<='Z')
        {
            dx1();
            an(int(t));
            dx2();
        }
        else if(t>='0'&&t<='9')
            an(int(t));
        else if(t=='~'||t=='!'||t=='@'||t=='#'||t=='$'||t=='%'||t=='^'||t=='&'||t=='*'||t=='('||t==')'||t=='_'||t=='+'||t=='{'||t=='}'||t=='|'||t==':'||t=='"'||t=='?'||t=='<'||t=='>')
        {
            dx1();
            if(t=='~')
                an(192);
            else if(t=='!')
                an(49);
            else if(t=='@')
                an(50);
            else if(t=='#')
                an(51);
            else if(t=='$')
                an(52);
            else if(t=='%')
                an(53);
            else if(t=='^')
                an(54);
            else if(t=='&')
                an(55);
            else if(t=='*')
                an(56);
            else if(t=='(')//****************************
            {
                an(57);
                an(46);
            }
            else if(t==')')
                an(48);
            else if(t=='_')
                an(189);
            else if(t=='+')
                an(187);
            else if(t=='{')
                an(219);
            else if(t=='}')
                an(221);
            else if(t=='|')
                an(220);
            else if(t==':')
                an(186);
            else if(t=='"')//***********
            {
                an(222);
                an(46);
            }
            else if(t=='?')
                an(191);
            else if(t=='<')
            {
                an(188);
                an(46);
            }
            else if(t=='>')
            {
                an(190);
            }
            dx2();
        }
        else
        {
            if(t=='`')
                an(192);
            else if(t=='-')
                an(189);
            else if(t=='=')
                an(187);
            else if(t=='[')//************
            {
                an(219);
                an(46);
            }
            else if(t==']')
                an(221);
            else if(t=='\\')
                an(220);
            else if(t==';')
                an(186);
            else if(t=='\'')//************
            {
                an(222);
                an(46);
            }
            else if(t=='/')
                an(191);
            else if(t==',')
            {
                an(188);
            }
            else if(t=='.')
            {
                an(190);
            }
        }
    }
}
posted @ 2019-12-09 13:44  <安排>  阅读(15)  评论(0编辑  收藏  举报