• 个人简介

    我叫托亚之王 一枚四年级的小学生

    【置顶】:【**联:神经中枢爆炸紧急扔进垃圾桶剥皮喂我家电视机 下联:小脑外围萎缩迅速丢出卫生间敲碎喂铁一评测机*】

    隔壁补胎的师傅受到启发,给自己取了一个国际范的名字:​**拿破轮**​。电焊工听到,受到启发,也给自己取了
    —————————————————————————下一段————————————————————————
    
    西江月·证明
    
    即得易见平凡,仿照上例显然。留作习题答案略,读者自证不难。
    
    反之亦然同理,推论自然成立,略去过程QED,由上可知证毕。
    
    —————————————————————————下一段————————————————————————
    
    北冥有鱼,其名为鲲,鲲之大,long long double 装不下;化而为鸟,其名为鹏,鹏之大,高精数组都爆炸。
    
    —————————————————————————下一段————————————————————————
    
    魔鬼:我可以实现你三个愿望,然后我就杀了你
    
    程序员:请实现我第二个愿望
    
    程序员:请实现我第一个愿望
    
    魔鬼.exe 已停止运行
    
    #include <iostream>
    using namespace std;
    
    int main() {
        while(1) cout << "mc启动!!!" << endl;
        return 0;
    }
    

    Copy


    如果26个英文字母

    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

    分别等于

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

    那么

    Knowledge (知识): K+N+O+W+L+E+D+G+E= 11+14+15+23+12+5+4+7+5=96%。

    Workhard (努力工作):W+O+R+K+H+A+R+D= 23+15+18+11+8+1+18+4 =98%。

    也就是说知识和努力工作对我们人生的影响可以达到96%和98%。

    Luck(好运) L+U+C+K=12+21+3+11=47%。

    Love(爱情) L+O+V+E=12+15+22+5=54%。

    看来,这些我们通常认为重要的东西却并没起到最重要的作用。

    那么,什么可以决定我们100%的人生呢?

    其实,真正能使我们生活圆满的东西就在我们的代码里面!

    IOSTREAM(输入输出流所在的头文件)=9+15+19+20+18+5+1+13=100%。

    所以认真写代码吧

    C++格言:暴力出奇迹,打表进省一。 数学先打表,DP 看运气。 穷举 TLE ,递推 UKE 。 模拟 MLE ,贪心还CE 。 想要骗到分,就要有方法。 图论背模板,数论背公式。 动规背方程,高精背代码。 骗分过样例,FO 得 AC


    初墨,多么优雅的名字——可惜他姓熊
    
    拔杰,多么高端的名字——可惜他姓朱
    
    渔歌,多么诗意的名字——可惜他姓章
    
    楚衢,多么凝重的名字——可惜他姓滚
    
    巅峰,多么上进的名字——可惜他姓杨
    
    紫藤,多么大气的名字——可惜他姓杜
    
    晶斌,多么文静的名字——可惜他姓沈
    
    泥马,多么深奥的名字——可惜他姓曹
    
    珍香,多么秀丽的名字——可惜他姓史
    
    达野,多么磅礴的名字——可惜他姓尼
    
    仁范,多么仁慈的名字——可惜他姓沙
    
    塞克,多么科技的名字——可惜他姓马
    
    思,多么文静的名字——可惜他姓刁
    

    Copy


    语文老师一回头,此地空无黄鹤楼。
    
    数学老师一回头,二次函数对称轴。
    
    英语老师一回头,Sorry加上三克油。
    
    历史老师一回头,秦始皇来打酱油。
    
    化学老师一回头,二氧化碳变汽油。
    
    生物老师一回头,试管婴儿水中游。
    
    音乐老师一回头,打着节拍摇着头。
    
    政治老师一回头,学霸学渣搞金融。
    
    美术老师一回头,蒙娜丽莎也风流。
    
    物理老师一回头,阿基米德要跳楼。
    
    天文老师一回头,火星也来撞地球。
    
    地理老师一回头,地球原来是个球。
    
    体育老师一回头,乔丹改打乒乓球。
    
    电脑老师一回头,学生请假有理由。
    
    足球老师一回头,全班同学都梦游。
    
    建筑老师一回头,吓塌一栋七层楼。
    
    心理老师一回头,癞蛤蟆也变温柔。
    
    劳技老师一回头,破铜烂铁来走秀。
    
    科学老师一回头,日食月食每天有。
    
    思品老师一回头,鲁迅甘为孺子牛。
    
    综合老师一回头,就算是鬼也发愁。
    
    全体老师一回头,全体学生没自由。
    

    Copy


    你不得不承认,7个事实
    
    1.你的脖子转不了两圈。
    
    2.你数不了你有多少头发。
    
    3.当你舌头伸出来的时候你不能用鼻子呼吸。 
    
    4.你正在做第三条。
    
    5.当你在做第三条的时候,其实你觉得是可行的,但是你看起来会像条小狗一样。
    
    6.你现在在笑,因为我把你整了。
    
    7.分享出去,你就可以整别人报仇了。
    
    哈哈哈!!!
    

    Copy


    "AC=Answer Coarse=粗劣的答案"
    
    "WA=Wonderful Answer=好答案"
    
    "TLE=Time Limit Enough=时间充裕"
    
    "MLE=Memory Limit Enough=内存充裕"
    
    "CE=Compile Easily=轻松通过编译"
    
    "RE=Run Excellently=完美运行"
    
    "UKE=Unbelievablly Keep Enough Score=难以置信地保持足够的分数"
    
    "AU=All Unaccepted=全都不正确"
    

    Copy


    各种人的a+b问题做法:

    普通人:

    #include <iostream>
    #include <cstdio>
    
    using namespace std;
    
    int main() {
        int a,b;
        cin >> a >> b;
        cout << a+b;
        return 0;
    }
    

    Copy

    树状数组 高手:

    #include<iostream>
    #include<cstring>
    using namespace std;
    int lowbit(int a)
    {
        return a&(-a);
    }
    int main()
    {
        int n=2,m=1;
        int ans[m+1];
        int a[n+1],c[n+1],s[n+1];
        int o=0;
        memset(c,0,sizeof(c));
        s[0]=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            s[i]=s[i-1]+a[i];
            c[i]=s[i]-s[i-lowbit(i)];//树状数组创建前缀和优化
        }
        for(int i=1;i<=m;i++)
        {
            int q=2;
            //if(q==1)
            //{(没有更改操作)
            //    int x,y;
            //    cin>>x>>y;
            //    int j=x;
            //    while(j<=n)
            //    {
            //        c[j]+=y;
            //        j+=lowbit(j);
            //    }
            //}
            //else
            //{
                int x=1,y=2;//求a[1]+a[2]的和
                int s1=0,s2=0,p=x-1;
                while(p>0)
                {
                    s1+=c[p];
                    p-=lowbit(p);//树状数组求和操作,用两个前缀和相减得到区间和
                }
                p=y;
                while(p>0)
                {
                    s2+=c[p];
                    p-=lowbit(p);
                }    
                o++;
                ans[o]=s2-s1;//存储答案
            //}
        }
        for(int i=1;i<=o;i++)
            cout<<ans[i]<<endl;//输出
        return 0;
    }
    

    Copy

    图论高手(Dijkstra+优先队列优化):

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <climits>
    #include <algorithm>
    #include <map>
    #include <queue>
    #include <vector>
    #include <ctime>
    #include <string>
    #include <cstring>
    using namespace std;
    const int N=405;
    struct Edge {
        int v,w;
    };
    vector<Edge> edge[N*N];
    int n;
    int dis[N*N];
    bool vis[N*N];
    struct cmp {
        bool operator()(int a,int b) {
            return dis[a]>dis[b];
        }
    };
    int Dijkstra(int start,int end)
    {
        priority_queue<int,vector<int>,cmp> dijQue;
        memset(dis,-1,sizeof(dis));
        memset(vis,0,sizeof(vis));
        dijQue.push(start);
        dis[start]=0;
        while(!dijQue.empty()) {
            int u=dijQue.top();
            dijQue.pop();
            vis[u]=0;
            if(u==end)
                break;
            for(int i=0; i<edge[u].size(); i++) {
                int v=edge[u][i].v;
                if(dis[v]==-1 || dis[v]>dis[u]+edge[u][i].w) {
                    dis[v]=dis[u]+edge[u][i].w;
                    if(!vis[v]) {
                        vis[v]=true;
                        dijQue.push(v);
                    }
                }
            }
        }
        return dis[end];
    }
    int main()
    {
        int a,b;
        scanf("%d%d",&a,&b);
        Edge Qpush;
        
        Qpush.v=1;
        Qpush.w=a;
        edge[0].push_back(Qpush);
        
        Qpush.v=2;
        Qpush.w=b;
        edge[1].push_back(Qpush);
        
        printf("%d",Dijkstra(0,2));
        return 0;
    }
    

    Copy

    字典树高手:

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    using namespace std;
    struct node{
        int str[26];
        int sum;
    }s[1000];
    char str1[100];
    int t=0,tot=0,ss=0;
    bool f1;
    void built()
    {
        t=0;
        for(int i=0;i<strlen(str1);i++)
        {
             if(str1[i]=='-'){
                 f1=true;continue;
             }
             if(!s[t].str[str1[i]-'0'])
             s[t].str[str1[i]-'0']=++tot;
             t=s[t].str[str1[i]-'0'];
             s[t].sum=str1[i]-'0';
        }
    }
    int query()
    {
       int t=0;int s1=0;
       for(int i=0;i<strlen(str1);i++)
       {
               if(str1[i]=='-') continue;
               if(!s[t].str[str1[i]-'0']) return s1;
               t=s[t].str[str1[i]-'0'];
               s1=s1*10+s[t].sum;
       }
       return s1;
    }
    int main()
    {    
      for(int i=1;i<=2;i++)
      {
          f1=false;
          scanf("%s",str1);
        built();
        if(f1)
          ss-=query();
          else ss+=query();
      }
      printf("%d",ss);
      return 0;    
    }
    

    Copy

    线段树高手:

    #include<cstdio>
    #include<algorithm>
    #include<cstdlib>
    #include<cmath>
    #include<cstring>
    #include<iostream>
    using namespace std;
    struct node{
        int val,l,r;
    };
    node t[5];
    int a[5],f[5];
    int n,m;
    void init(){
        for(int i=1;i<=2;i++){
            scanf("%d",&a[i]);
        }
    }
    void build(int l,int r,int node){//这是棵树
        t[node].l=l;t[node].r=r;t[node].val=0;
        if(l==r){
            f[l]=node;
            t[node].val=a[l];
            return;
        }
        int mid=(l+r)>>1;
        build(l,mid,node*2);
        build(mid+1,r,node*2+1);
        t[node].val=t[node*2].val+t[node*2+1].val;
    }
    void update(int node){
        if(node==1)return;
        int fa=node>>1;
        t[fa].val=t[fa*2].val+t[fa*2+1].val;
        update(fa);
    }
    int find(int l,int r,int node){
        if(t[node].l==l&&t[node].r==r){
            return t[node].val;
        }
        int sum=0;
        int lc=node*2;int rc=lc+1;
        if(t[lc].r>=l){
            if(t[lc].r>=r){
                sum+=find(l,r,lc);
            }
            else{
                sum+=find(l,t[lc].r,lc);
            }
        }
        if(t[rc].l<=r){
            if(t[rc].l<=l){
                sum+=find(l,r,rc);
            }
            else{
                sum+=find(t[rc].l,r,rc);
            }
        }
        return sum;
    }
    int main(){
        init();
        build(1,2,1);
        printf("%d",find(1,2,1));
    }
    

    Copy

    最小生成树高手:

    #include <cstdio>
    #include <algorithm>
    #define INF 2140000000
    using namespace std;
    struct tree{int x,y,t;}a[10];
    bool cmp(const tree&a,const tree&b){return a.t<b.t;}
    int f[11],i,j,k,n,m,x,y,t,ans;
    int root(int x){if (f[x]==x) return x;f[x]=root(f[x]);return f[x];}
    int main(){
        for (i=1;i<=10;i++) f[i]=i;
        for (i=1;i<=2;i++){
            scanf("%d",&a[i].t);
            a[i].x=i+1;a[i].y=1;k++;
        }
        a[++k].x=1;a[k].y=3,a[k].t=INF;
        sort(a+1,a+1+k,cmp);
        for (i=1;i<=k;i++){
        //    printf("%d %d %d %d\n",k,a[i].x,a[i].y,a[i].t);
            x=root(a[i].x);y=root(a[i].y);
            if (x!=y) f[x]=y,ans+=a[i].t; 
        }
        printf("%d\n",ans);
    }
    

    Copy

    Splay高手:

    //一颗资瓷区间加、区间翻转、区间求和的Splay
    #include <bits/stdc++.h>
    #define ll long long
    #define N 100000
    using namespace std;
    int sz[N], rev[N], tag[N], sum[N], ch[N][2], fa[N], val[N];
    int n, m, rt, x;
    void push_up(int x){
        sz[x] = sz[ch[x][0]] + sz[ch[x][1]] + 1;
        sum[x] = sum[ch[x][1]] + sum[ch[x][0]] + val[x];
    }
    void push_down(int x){
        if(rev[x]){
            swap(ch[x][0], ch[x][1]);
            if(ch[x][1]) rev[ch[x][1]] ^= 1;
            if(ch[x][0]) rev[ch[x][0]] ^= 1;
            rev[x] = 0;
        }
        if(tag[x]){
            if(ch[x][1]) tag[ch[x][1]] += tag[x], sum[ch[x][1]] += tag[x];
            if(ch[x][0]) tag[ch[x][0]] += tag[x], sum[ch[x][0]] += tag[x];
            tag[x] = 0;
        }
    }
    void rotate(int x, int &k){
        int y = fa[x], z = fa[fa[x]];
        int kind = ch[y][1] == x;
        if(y == k) k = x;
        else ch[z][ch[z][1]==y] = x;
        fa[x] = z; fa[y] = x; fa[ch[x][!kind]] = y;
        ch[y][kind] = ch[x][!kind]; ch[x][!kind] = y;
        push_up(y); push_up(x);
    }
    void splay(int x, int &k){
        while(x != k){
            int y = fa[x], z = fa[fa[x]];
            if(y != k) if(ch[y][1] == x ^ ch[z][1] == y) rotate(x, k);
            else rotate(y, k);
            rotate(x, k);
        }
    }
    int kth(int x, int k){
        push_down(x);
        int r = sz[ch[x][0]]+1;
        if(k == r) return x;
        if(k < r) return kth(ch[x][0], k);
        else return kth(ch[x][1], k-r);
    }
    void split(int l, int r){
        int x = kth(rt, l), y = kth(rt, r+2);
        splay(x, rt); splay(y, ch[rt][1]);
    }
    void rever(int l, int r){
        split(l, r);
        rev[ch[ch[rt][1]][0]] ^= 1;
    }
    void add(int l, int r, int v){
        split(l, r);
        tag[ch[ch[rt][1]][0]] += v;
        val[ch[ch[rt][1]][0]] += v;
        push_up(ch[ch[rt][1]][0]);
    }
    int build(int l, int r, int f){
        if(l > r) return 0;
        if(l == r){
            fa[l] = f;
            sz[l] = 1;
            return l;
        }
        int mid = l + r >> 1;
        ch[mid][0] = build(l, mid-1, mid);
        ch[mid][1] = build(mid+1, r, mid);
        fa[mid] = f;
        push_up(mid);
        return mid;
    }
    int asksum(int l, int r){
        split(l, r);
        return sum[ch[ch[rt][1]][0]];
    }
    int main(){
        //总共两个数
        n = 2;
        rt = build(1, n+2, 0);//建树
        for(int i = 1; i <= n; i++){
            scanf("%d", &x);
            add(i, i, x);//区间加
        }
        rever(1, n);//区间翻转
        printf("%d\n", asksum(1, n));//区间求和
        return 0;
    }
    

    Copy

    ~这玩意我也看蒙了~ 你们能看懂几个呢?(不包括第一个)


    ______  __  __      ______   _____   ______       _____
    /\  _  \/\ \/\ \    /\__  _\ /\  __ \/\__  _\     /\    \
    \ \ \ \ \ \ \/ /    \/_/\ \/ \ \ \/\ \/_/\ \/     \ \   |
     \ \  __ \ \   <       \ \ \  \ \ \ \ \ \ \ \      \ \  |
      \ \ \/\ \ \ \\ \      \_\ \__\ \ \_\ \ \_\ \__    \ \ |
       \ \_\ \_\ \_\ \_\    /\_____\\ \_____\/\_____\    \_\/
        \/_/\/_/\/_/\/_/    \/_____/ \/_____/\/_____/      ●
    

    Copy


    离离原上谱,一岁一离谱。离谱烧不尽,冬风吹又生。远芳侵谱道,晴翠接离城。又送离谱去,萋萋四十九。

    小游戏:

    #include<iostream>
    using namespace std;
    int main() {
    	long long qian = 10, aden = 1, amin = 20, yao = 0, aminx = 20, agong = 0, agongg = 5, afang = 0, mg[5] = {5, 20, 30, 40, 50}, mq[5] = {2, 10, 20, 50, 100}, mm[5] = {20, 40, 60, 80, 100}, a, b = 0, c, d;
    	cout << "1.资源商店" << endl;
    	cout << "2.获得宠物" << endl;
    	cout << " 3.出战" << endl;
    	cout << "恭喜获得新人礼包:金币*1" << endl;
    	cin >> b;
    	if (b == 1 || b == 3) {
    		cout << "请先获得宠物" << endl;
    		cout << "1.小猫 收费:金币*1" << endl;
    		cout << "2.小狗 收费:金币*1" << endl;
    	} else if (b == 2) {
    		cout << "1.小猫 收费:金币*1" << endl;
    		cout << "2.小狗 收费:金币*1" << endl;
    	}
    	cin >> b;
    	if (b == 1) {
    		cout << "恭喜获得宠物:小猫" << endl;
    	} else if (b == 2) {
    		cout << "恭喜获得宠物:小狗" << endl;
    	}
    	cout << "成功获得宠物 奖励金币*10" << endl;
    	while (b != 9) {
    		cout << "1.资源商店" << endl;
    		cout << "2.宠物升级" << endl;
    		cout << "3.出战" << endl;
    		cout << "4.资料" << endl;
    		cout << "按9结束游戏" << endl;
    		cin >> b;
    		if (b == 9) {
    			cout << "感谢游玩" << endl;
    			return 0;
    		} else if (b == 1) {
    			cout << "1.装备" << endl;
    			cout << "2.药品" << endl;
    			cin >> a;
    			if (a == 1) {
    				cout << "1.攻击" << endl;
    				cout << "2.防御" << endl;
    				cin >> c;
    				if (c == 1) {
    					cout << "1.铁齿 (+20) 收费:金币*40" << endl;
    					cout << "2.钢毛 (+25) 收费:金币*50" << endl;
    					cout << "3.铜爪 (+30) 收费:金币*60" << endl;
    					cout << "4.银掌 (+50) 收费:金币*100" << endl;
    					cout << "5.远古石球 (+100) 收费:金币*300" << endl;
    					cin >> d;
    					if (d == 5 && qian >= 300) {
    						agong += 100;
    						qian -= 300;
    						cout << "当前攻击力:" << agong << endl;
    					} else if (d == 1 && qian >= 40) {
    						agong += 20;
    						qian -= 40;
    						cout << "当前攻击力:" << agong << endl;
    					} else if (d == 2 && qian >= 50) {
    						agong += 25;
    						qian -= 50;
    						cout << "当前攻击力:" << agong << endl;
    					} else if (d == 3 && qian >= 60) {
    						agong += 30;
    						qian -= 60;
    						cout << "当前攻击力:" << agong << endl;
    					} else if (d == 4 && qian >= 100) {
    						agong += 50;
    						qian -= 100;
    						cout << "当前攻击力:" << agong;
    					} else if (d == 1 || d == 2 || d == 3 || d == 4 || d == 5) {
    						cout << "金币不够" << endl << "当前金币:" << qian << endl;
    					}
    				}
    				if (c == 2) {
    					cout << "1.铁甲 (%20) 收费:金币*40" << endl;
    					cout << "2.钢甲 (%30) 收费:金币*50" << endl;
    					cout << "3.铜甲 (%40) 收费:金币*60" << endl;
    					cout << "4.银甲 (%50) 收费:金币*100" << endl;
    					cout << "5.时空金甲 (%90) 收费:金币*300" << endl;
    					cin >> d;
    					if (d == 5 && qian >= 300) {
    						afang = 1;
    						qian -= 300;
    						amin += 150;
    						cout << "当前防御力:%" << afang << endl << "当前血量总值:" << amin << endl;
    					} else if (d == 1 && qian >= 40) {
    						afang = 8;
    						qian -= 40;
    						amin += 20;
    						cout << "当前防御力:%" << afang << endl << "当前血量总值:" << amin << endl;
    					} else if (d == 2 && qian >= 50) {
    						afang = 7;
    						qian -= 50;
    						amin += 25;
    						cout << "当前防御力:%" << afang << endl << "当前血量总值:" << amin << endl;
    					} else if (d == 3 && qian >= 60) {
    						afang = 6;
    						qian -= 60;
    						amin += 30;
    						cout << "当前防御力:%" << afang << endl << "当前血量总值:" << amin << endl;
    					} else if (d == 4 && qian >= 100) {
    						afang = 5;
    						qian -= 100;
    						amin += 50;
    						cout << "当前防御力:%" << afang << endl << "当前血量总值:" << amin << endl;
    					} else if (d == 1 || d == 2 || d == 3 || d == 4 || d == 5) {
    						cout << "金币不够" << endl << "当前金币:" << qian << endl;
    					}
    				}
    			}
    			if (a == 2) {
    				cout << "1.血液回满 收费:金币*1" << endl;
    				cout << "2.快速回复*5(可在战斗中使用) 收费:金币*2" << endl;
    				cin >> c;
    				if (c == 1 && qian >= 1) {
    					aminx = amin;
    					qian -= 1;
    					cout << "当前血量:" << aminx << endl;
    				} else if (c == 1) {
    					cout << "金币不够" << endl << "当前金币:" << qian << endl;
    				}
    				if (c == 2 && qian >= 2) {
    					yao += 5;
    					cout << "当前药品量:" << yao << endl;
    					qian -= 2;
    				} else if (c == 2) {
    					cout << "金币不够" << endl << "当前金币:" << qian << endl;
    				}
    			}
    		} else if (b == 2) {
    			if (afang < 20 && agong < 20) {
    				cout << "请先获得至少一件攻击用具和至少一件防御用具" << endl;
    			} else {
    				cout << "当前等级为" << aden << "级,晋级需要金币*" << aden * 100 << "是否晋级?" << endl;
    				cout << "1.是" << endl;
    				cout << "2.否" << endl;
    				cin >> a;
    				if (a == 1 && qian >= aden * 100) {
    					aden++;
    					agongg *= 2;
    					amin *= 2;
    					qian += aden * 10;
    					cout << "恭喜晋级成功,获得奖励:金币*" << aden * 10 << endl;
    				} else if (a == 1) {
    					cout << "金币不够" << endl << "当前金币:" << qian << endl;
    				}
    			}
    		} else if (b == 3 && aminx > 0) {
    			cout << "1.小怪 攻击力:5 生命值:30" << endl;
    			cout << "2.小怪之王 攻击力:20 生命值:90" << endl;
    			cout << "3.小魔头 攻击力:30 生命值:90" << endl;
    			cout << "4.大魔头 攻击力:40 生命值:120" << endl;
    			cout << "5.万魔之王 攻击力:50 生命值:150" << endl;
    			cin >> a;
    			cout << "开始战斗" << endl;
    			if (afang != 0) {
    				mg[a - 1] /= 10;
    				mg[a - 1] *= afang;
    			}
    			while (aminx > 0 && mm[a - 1] > 0) {
    				cout << "1.攻击" << endl;
    				cout << "2.快速回复" << endl;
    				cin >> c;
    				if (c == 1) {
    					mm[a - 1] -= (agong + agongg);
    					aminx -= mg[a - 1];
    					cout << "魔兽血量-" << agong + agongg << "=" << mm[a - 1] << endl << "宠物血量-" << mg[a - 1] << "=" << aminx << endl;
    				} else if (c == 2) {
    					if (yao > 0) {
    						yao--;
    						aminx = amin;
    						cout << "当前血量:" << aminx << endl;
    						cout << "剩余药品量:" << yao << endl;
    					} else {
    						cout << "药品不足" << endl;
    					}
    				}
    			}
    			if (mm[a - 1] <= 0 && aminx > 0) {
    				cout << "挑战成功" << endl << "获得奖励 金币*" << mq[a - 1] << endl;
    				qian += mq[a - 1];
    				if (a != 1) {
    					mg[a - 1] = a * 5 * 2;
    					mm[a - 1] = mg[a - 1] / 2 * 4;
    				} else {
    					mg[a - 1] = 5;
    					mm[a - 1] = 20;
    				}
    			} else {
    				cout << "你死了" << endl;
    				if (a != 1) {
    					mg[a - 1] = a * 5 * 2;
    					mm[a - 1] = mg[a - 1] / 2 * 4;
    				} else {
    					mg[a - 1] = 5;
    					mm[a - 1] = 20;
    				}
    			}
    		} else if (b == 3) {
    			cout << "您的宠物已经没有血了,请先补满血再来" << endl;
    		} else if (b == 4) {
    			cout << "-------------------------" << endl;
    			cout << "|血量总值:" << amin << " ";
    			cout << "当前血量:" << aminx << endl;
    			cout << "|当前金币:" << qian << " ";
    			cout << "当前攻击力:" << agong + agongg << endl;
    			if (afang != 0) {
    				cout << "|当前防御力:%" << (10 - afang) * 10 << " ";
    			} else {
    				cout << "|当前防御力:%0" << " ";
    			}
    			cout << "当前药品量:" << yao << endl;
    		}
    	}
    	return 0;
    }
    

    贪吃蛇:

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <ctime>
    #include <conio.h>
    #include <cmath>
     #include <windows.h>
    using namespace std;
    
    /*** 光标定位 ***/
    HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coord;
    
    void locate(int x, int y) {
    	coord.X = y;
    	coord.Y = x;
    	SetConsoleCursorPosition(hout, coord);
    };
    
    /*** 隐藏光标 ***/
    void hide() {
    	CONSOLE_CURSOR_INFO cursor_info = {1, 0};
    	SetConsoleCursorInfo(hout, &cursor_info);
    }
    
    /*** 生成随机数 ***/
    double random(double start, double end) {
    	return start + (end - start) * rand() / (RAND_MAX + 1.0);
    }
    
    /*** 定义地图的长宽,蛇的坐标,长度,方向,食物的位置 ***/
    int m, n;
    
    struct node {
    	int x, y;
    } snake[1000];
    
    int snake_length, dir;
    node food;
    int direct[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    
    /*** 输出墙 ***/
    void print_wall() {
    	cout << " ";
    	for (int i = 1; i <= n; i++)
    		cout << "-";
    	cout << endl;
    	for (int j = 0; j <= m - 1; j++) {
    		cout << "|";
    		for (int i = 1; i <= n; i++) cout << " ";
    		cout << "|" << endl;
    	}
    	cout << " ";
    	for (int i = 1; i <= n; i++)
    		cout << "-";
    }
    
    /*** 首次输出蛇,其中snake[0]代表头 ***/
    void print_snake() {
    	locate(snake[0].x, snake[0].y);
    	cout << "@";
    	for (int i = 1; i <= snake_length - 1; i++) {
    		locate(snake[i].x, snake[i].y);
    		cout << "*";
    	}
    }
    
    /*** 判断是否撞墙或者自撞 ***/
    bool is_correct() {
    	if (snake[0].x == 0 || snake[0].y == 0 || snake[0].x == m + 1 || snake[0].y == n + 1) return false;
    	for (int i = 1; i <= snake_length - 1; i++) {
    		if (snake[0].x == snake[i].x && snake[0].y == snake[i].y) return false;
    	}
    	return true;
    }
    
    /*** 随机生成并输出食物位置 ***/
    bool print_food() {
    	srand((unsigned)time(0));
    	bool e;
    	while (1) {
    		e = true;
    		int i = (int) random(0, m) + 1, j = (int) random(0, n) + 1;
    		food.x = i;
    		food.y = j;
    		for (int k = 0; k <= snake_length - 1; k++) {
    			if (snake[k].x == food.x && snake[k].y == food.y) {
    				e = false;
    				break;
    			}
    		}
    		if (e) break;
    	}
    	locate(food.x, food.y);
    	cout << "$";
    	return true;
    }
    
    /*** 蛇的前进 ***/
    bool go_ahead() {
    	node temp;
    	bool e = false;
    	temp = snake[snake_length - 1];
    	for (int i = snake_length - 1; i >= 1; i--)
    		snake[i] = snake[i - 1];
    	snake[0].x += direct[dir][0];
    	snake[0].y += direct[dir][1];
    	locate(snake[1].x, snake[1].y);
    	cout << "*";
    	/*** 吃到了食物 ***/
    	if (snake[0].x == food.x && snake[0].y == food.y) {
    		snake_length++;
    		e = true;
    		snake[snake_length - 1] = temp;
    	}
    	/*** 输出此时蛇状态 ***/
    	if (!e) {
    		locate(temp.x, temp.y);
    		cout << " ";
    	} else
    		print_food();
    	locate(snake[0].x, snake[0].y);
    	cout << "@";
    	/*** 如果自撞 ***/
    	if (!is_correct()) {
    		system("cls");
    		cout << "You lose!" << endl << "Length: " << snake_length << endl;
    		return false;
    	}
    	return true;
    }
    
    /*** 主函数 ***/
    int main() {
    	cout << "--------------------贪吃蛇---------------------" << endl;
    	cout << "请注意窗口大小,以免发生错位.建议将窗口调为最大." << endl;
    	cout << "先选择难度.请在1-10中输入1个数,1最简单,10则最难" << endl;
    	cout << "然后进入游戏画面,以方向键控制方向.祝你游戏愉快!" << endl;
    	cout << "-----------------------------------------------" << endl;
    	m = 25;
    	n = 40;
    	if (m < 10 || n < 10 || m > 25 || n > 40) {
    		cout << "ERROR" << endl;
    		system("pause");
    		return 0;
    	}
    	int hard;
    	cin >> hard;
    	if (hard <= 0 || hard > 100) {
    		cout << "ERROR" << endl;
    		system("pause");
    		return 0;
    	}
    	/*** 数据全部初始化,包括蛇长,位置,方向 ***/
    	snake_length = 5;
    	clock_t a, b;
    	char ch;
    	double hard_len;
    	for (int i = 0; i <= 4; i++) {
    		snake[i].x = 1;
    		snake[i].y = 5 - i;
    	}
    	dir = 3;
    	/*** 输出初始地图,蛇与食物 ***/
    	system("cls");
    	hide();
    	print_wall();
    	print_food();
    	print_snake();
    	locate(m + 2, 0);
    	cout << "Now length: ";
    	/*** 开始游戏 ***/
    	while (1) {
    		/*** 难度随长度增加而提高 ***/
    		hard_len = (double)snake_length / (double) (m * n);
    		/*** 调节时间,单位是ms ***/
    		a = clock();
    		while (1) {
    			b = clock();
    			if (b - a >= (int)(400 - 30 * hard) * (1 - sqrt(hard_len))) break;
    		}
    		/*** 接受键盘输入的上下左右,并以此改变方向 ***/
    		if (kbhit()) {
    			ch = getch();
    			if (ch == -32) {
    				ch = getch();
    				switch (ch) {
    					case 72:
    						if (dir == 2 || dir == 3)
    							dir = 0;
    						break;
    					case 80:
    						if (dir == 2 || dir == 3)
    							dir = 1;
    						break;
    					case 75:
    						if (dir == 0 || dir == 1)
    							dir = 2;
    						break;
    					case 77:
    						if (dir == 0 || dir == 1)
    							dir = 3;
    						break;
    				}
    			}
    		}
    		/*** 前进 ***/
    		if (!go_ahead()) break;
    		/*** 在最后输出此时长度 ***/
    		locate(m + 2, 12);
    		cout << snake_length;
    	}
    	system("pause");
    	return 0;
    }