首页 > 编程语言 >【c++】游戏作品分享

【c++】游戏作品分享

时间:2024-11-13 20:16:13浏览次数:3  
标签:a% 游戏 int t2 c++ else time 分享 cout

 c++代码

#include <bits/stdc++.h>
#include <xiaohoucode.h>
#include<time.h>
#include<stdlib.h>
#include <unistd.h>
#include <termio.h>
#include <ctype.h>
#include <stdio.h>
#include<math.h>
using namespace std;
int cnt1=0;
int cnt2=0;
bool andchachengchu(int a1)
{
    while (cnt1!=10)
    {
    	
    	cnt1++;
        srand((unsigned int)time(NULL));
        int a = rand() % 100 + 1;
        int b = rand() % 100 + 1;
        int c = rand() % 4 + 1;
        if (c == 1)
        {
            int da = a + b;
            cout << a << " + " << b << " = ";
            int n;
            cin >> n;
            if (n == da)
            {
                cout << "对了" << endl;
                cnt2++;
            }
            else
            {
                cout << "错了" << endl;
            }
        }
        if (c == 2)
        {
            int da = a + b;
            cout << a << " + " << b << " = ";
            int n;
            cin >> n;
            if (n == da)
            {
                cout << "对了" << endl;
                cnt2++;
            }
            else
            {
                cout << "错了" << endl;
            }
        }
        if (c == 3)
        {
            double da = a * b;
            cout << a << " * " << b << " = ";
            int n;
            cin >> n;
            if (n == da)
            {
                cout << "对了" << endl;
                cnt2++;
            }
            else
            {
                cout << "错了" << endl;
            }
        }
        if (c == 4)
        {
            if (a < b)
            {
                int temp = a;
                a = b;
                b = temp;
            }
            bool flag = false;
            for (int i = a; i >= 1; i--)
            {
                for (int j = b; j >= 1; j--)
                {
                   if (i % j == 0)
                   {
                       flag = true;
                       a = i;
                       b = j;
                       break;
                   }
                }
                if (flag)
                {
                    break;
                }
            }
            double da = a * 1.0 / b;
            cout << a << " / " << b << " = ";
            double n;
            cin >> n;
            if (n == da)
            {
                cout << "对了" << endl;
                cnt2++;
            }
            else
            {
                cout << "错了" << endl;
            }
        }
        
    }
    
}
int health1 = 5, health2 = 5;
int power1 = 0, power2 = 0;
int cnt = 0;
void intro1()
{
    srand(time(NULL));
    cout << endl << endl;
    cout << "两人回合制游戏,每回合双方同时在“攻击、防御、集气、必杀”四种行动中选一种。" << endl << endl;
    // 补充游戏介绍函数
    cout << "两人回合制游戏,每回合双方同时在“攻击、防御、集气、必杀”四种行动中选一种。" << endl << endl;
    cout << "1. “生命”:每人 5 点生命,生命归 0 立即死亡;" << endl << endl;
    cout << "2. “伤害”:攻击造成 1 伤害,防御免除攻击伤害,互相攻击双方都不受伤害,必杀造成 3 伤害;" << endl << endl;
    cout << "“必杀”:必杀需消耗 2“气”,双方同时必杀则相安无事,否则放必杀者造成伤害,对手的行动无任何效果;" << endl << endl;
    cout << "4. “气”:防御对方攻击增加 1 气,集气且不受到伤害增加 1 气。" << endl << endl;
    cout << "----------单挑开始,你是武将1,电脑指挥武将2----------" << endl << endl;
}
// 人的策略函数
namespace human
{
    int strategy()
    {
        // 输出出卡提示
        cout << "用数字代表本回合武将1的行动:1攻击,2防御,3集气,4必杀" << endl;
        // 读入人的策略
        int x;
        cin >> x;
        return x;
    }
}
// 片段4 确定电脑策略
// 确定电脑策略
namespace ai
{
    int strategy()
    {
        //补充函数:产生1~3的随机数,并返回
        if (power2 >= 2)return 4;
        {
            return rand() % 3 + 1;
        }
    }
}
//片段5 根据双方行动, 执行一回合的对战
bool fight(int d1, int d2)
{ 
    if (d1 < 1 || d1 > 4)
    {
        cout << "【【【武将1没有这种策略啦~重新开始回合" << cnt << "!】】】" << endl;
        return true;  
    }          
    if ((d1 == 4 && power1 < 2))
    {
        cout << "【【【武将1不够气来放必杀!重新开始回合" << cnt << "!】】】" << endl;
        return true;     
    }
    cout << "【【【" ;
    if (d1 == 1 && d2 == 1)
    {
        cout << "两人同时攻击,相安无事";
    }
    if (d1 == 1 && d2 == 2)
    {
        power2++;
        cout << "武将2防御了武将1的攻击,得1气";
    }
    if (d1 == 2 && d2 == 1)
    {
        power1++;
        cout << "武将1防御了武将2的攻击,得1气";
    }
    if (d1 == 2 && d2 == 2)
    {
        cout << "两人同时防御,相安无事";
    }
    if (d1 == 1 && d2 == 3)
    {
        health2--;
        cout << "武将2集气时受到武将1的攻击,损失1生命";
    }
    if (d1 == 3 && d2 == 1)
    {
        health1--;
        cout << "武将1集气时受到武将2的攻击,损失1生命";
    }
    if (d1 == 2 && d2 == 3)
    {
        power2++;
        cout << "武将2趁武将1防御时集气,得1气";
    }
    if (d1 == 3 && d2 == 2)
    {
        power1++;
        cout << "武将1趁武将2防御时集气,得1气";
    }
    if (d1 == 3 && d2 == 3)
    {
        power1++;
        power2++;
        cout << "双方同时集气,各得1气";
    }
    if (d1 == 4 && d2 != 4)
    {
        power1 -= 2;
        health2 -= 3;
        cout << "武将1使出必杀,对对手造成3伤害";
    }
    if (d1 != 4 && d2 == 4)
    {
        power2 -= 2;
        health1 -= 3;
        cout << "武将2使出必杀,对对手造成3伤害";
    }
    if (d1 == 4 && d2 == 4)
    {
        power1 -= 2;
        power2 -= 2;
        cout << "双方同时必杀,相安无事";
    }
    cout << "】】】" << endl;
    return false;
}
//片段6 本回合战后统计
void result()
{   
    cout << "【双方状态】" << endl;
    cout << "*武将1:  生命" << health1 << "   气" << power1 << endl;
    cout << "*武将2:  生命" << health2 << "   气" << power2 << endl << endl;        
}
//片段7 公布对战结果, winner == 1 代表武将1胜, winner == 2 代表武将2胜
void showWinner(int winner)
{ 
    cout << endl << "【单挑结束!!!!!】" << endl;
    if (winner == 1) cout << "武将1击败对手获胜!!!!" << endl;
    else cout << "武将2击败对手获胜!!!!" << endl;
    cout << endl << endl;
}
//片段2 进行游戏
int pk()
{
    for(;;)
    {
        // 一方倒下游戏结束
        if (health1 <= 0) return 2;
        if (health2 <= 0) return 1;
        cout << "【开始回合" << ++cnt << "】" << endl;
        // 片段3 确定人类策略, 
        int human = human::strategy();
        // 片段4 确定电脑策略
        int ai = ai::strategy();
        //片段5 对战
        bool err = fight(human, ai);
        //片段6 本回合战后统计
        if (!err) result();         
        else cnt--;
    }
}

int a[230];
string d[3]={" ","O","X"};
int correct, wrong;
int getch()
{// 不回显的输入
    struct termios nts, ots;
    // 得到当前终端(0表示标准输入)的设置
    if (tcgetattr(0, &ots) < 0) return EOF;
    // 设置终端为Raw原始模式,该模式下所有的输入数据以字节为单位被处理
    nts = ots;
    cfmakeraw(&nts); 
    // 设置上更改之后的设置
    if (tcsetattr(0, TCSANOW, &nts) < 0) return EOF;
    // 设置还原成老的模式
    int cr;
    cr = getchar();
    if (tcsetattr(0, TCSANOW, &ots) < 0)  return EOF;
    return cr;
}
int print(int black)
{// 打印0-9数字 black数字标黑
    cout << "\033[0;0H";
    for (int i = 1; i <= 10; i++)
    {
        if (i%10 == black)
            cout << "\033[7m " << i%10 << " \033[0m";
        else
            cout << "\033[47;30m " << i%10 << " \033[0m";
    }
}
int print_keyboard(char ch, string color)
{// 打印键盘 ch字符设定为color颜色,其余默认
    char key[5][15] = {
        "1234567890-=",
        "QWERTYUIOP[]\\",
        "ASDFGHJKL;'",
        "ZXCVBNM,./"
    };
    cout << "\033[2;1H";
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < i; j++)
        {
            cout << " ";
        }
        for (int j = 0; key[i][j] != 0; j++)
        {
            if (ch == key[i][j])
            {
                if (color == "black")
                    cout << "\033[7m " << key[i][j] << " \033[0m";
                else if (color == "green")
                    cout << "\033[42;30m " << key[i][j] << " \033[0m";
                else if (color == "red")
                    cout << "\033[41;30m " << key[i][j] << " \033[0m";
            }
            else
                cout << "\033[47;30m " << key[i][j] << " \033[0m"; 
        }
        cout << endl;
    }
}
int typewritting()
{// 打字过程,返回总用时
    // 键盘字符集
    char s[] = "1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
    int len = strlen(s);
    srand(time(0));
    correct = 0;
    wrong = 0;
    int sta = time(0);
    const int TIMES = 30; // 出题数
    int last = 0;
    for (int i = 1; i <= TIMES; i++)
    {
        cout << "\033c" << flush;
        cout << "对: " << correct << " 错: " << wrong << "\n";
        // 抽取键盘字符集下标
        int r = rand() % len;
        // 避免连续两次按键相同
        while (r == last) r = rand() % len;
        last = r;
        print_keyboard(s[r], "black");
        char ch = getch();
        if (ch == s[r] || (islower(ch) && ch == tolower(s[r])))
        {
            print_keyboard(s[r], "green");
            correct++;
        }
        else
        {
            if (islower(ch))
                print_keyboard(toupper(ch), "red");
            else
                print_keyboard(ch, "red");
            wrong++;
        }
        usleep(100000);
    }
    int end = time(0);
    return end - sta;
}
void intro()
{// 规则介绍
    cout << "\033c" << flush;
    cout << "欢迎使用C++打字通!" << endl;
    sleep(1);
    cout << "开始后,你需要用最快的速度按下黑色字符所对应的按键。" << endl;
    sleep(1);
    cout<<"共30个字符。"<<endl;
    sleep(1);
    cout << "*注意:请将输入法改为英文!" << endl;
    sleep(1);
    cout << "准备好了嘛?" << endl;
    cout << "\033c" << flush;
    cout << "3" << endl;
    sleep(1);
    cout << "2" << endl;
    sleep(1);
    cout << "1" << endl;
    sleep(1);
    cout << "开始!" << endl;
    usleep(300000);
}
// 问题和答案的结构体
struct Question {
    string question;
    string answer;
};
// 初始化问题和答案
void initQuestions(Question questions[]) {
    questions[0] = {"What is the capital of France?", "Paris"};
    questions[1] = {"What is the largest planet in our solar system?", "Jupiter"};
    questions[2] = {"Which country is known as the Land of the Rising Sun?", "Japan"};
    questions[3] = {"What is the currency of China?", "Yuan"};
    questions[4] = {"Is orange round?", "Yes"};
    questions[5] = {"What is the chemical symbol for gold?", "Au"};
    questions[6] = {"Is James a basketball player?", "Yes"};
    questions[7] = {"Usain Bolt is fast or slow?", "fast"};
    questions[8] = {"Which animal is known as the 'King of the Jungle'?", "Lion"};
    questions[9] = {"What is the day between Monday and Wednesday?", "Tuesday"};
    
}
const int ROW = 10;
const int COL = 10;
const int MINE_NUM = 10;
vector<vector<int>> mineMap(ROW, vector<int>(COL, 0));
vector<vector<int>> showMap(ROW, vector<int>(COL, -1));
bool checkBound(int x, int y)
{
    if (x < 0 || x >= ROW || y < 0 || y >= COL) return false;
    return true;
}
void randomMine()
{
    int count = 0;
    while (count < MINE_NUM) {
        int x = rand() % ROW;
        int y = rand() % COL;
        if (mineMap[x][y] == 0) {
            mineMap[x][y] = 9;
            count++;
        }
    }
}
int calCount(int x, int y)
{
    int count = 0;
    for (int i = x - 1; i <= x + 1; i++) {
        for (int j = y - 1; j <= y + 1; j++) {
            if (checkBound(i, j) && mineMap[i][j] == 9) count++;
        }
    }
    return count;
}
void spread(int x, int y)
{
    if (!checkBound(x, y) || showMap[x][y] > -1 || mineMap[x][y] == 9) return;
    int count = calCount(x, y);
    showMap[x][y] = count;
    if (count == 0) {
        spread(x - 1, y - 1);
        spread(x - 1, y);
        spread(x - 1, y + 1);
        spread(x, y - 1);
        spread(x, y + 1);
        spread(x + 1, y - 1);
        spread(x + 1, y);
        spread(x + 1, y + 1);
    }
}
void printMap()
{
	for (int i = 0; i < ROW; i++)
    {
    	cout << i << " ";
        for (int j = 0; j < COL; j++)
        {
            if (showMap[i][j] == -1)
            {
                cout << "* ";
            }
            else if (showMap[i][j] == 0)
            {
                cout << "  ";
            } 
            else if (showMap[i][j] == 10) 
            {
                cout << "X ";
            } 
            else 
            {
                cout << showMap[i][j] << " ";
            }
        }
        cout << endl;
    }
}
bool checkWin()
{
    for (int i = 0; i < ROW; i++)
    {
        for (int j = 0; j < COL; j++)
        {
            if (showMap[i][j] == -1 && mineMap[i][j] != 9)
            {
                return false;
            }
        }
    }
    return true;
}
int program()
{
	cout << "想体验哪种模式(1 : 挑战模式,2 : 练习模式):" << "\n";
	int x;
	cin >> x;
	if(x == 1)
	{
		srand((unsigned)time(NULL));
		randomMine();
		while (true) {
			cout << "  0 1 2 3 4 5 6 7 8 9\n";
		    printMap();
		    char cx, cy;
		    cout << "请输入要打开的位置坐标(如0(x)1(y)),或输入-1结束游戏:" << endl;
			cin >> cx >> cy;
			int x = cx - '0',y = cy - '0';
		    if(x == 12345666787878 && y == 45456663222) {
		    	cout << "你赢了!高手高高手!" << endl;
		        break;
		    }
		    if (x == -1 || y == -1) {
		        break;
		    }
		    if (mineMap[x][y] == 9) {
		        cout << "你输了,请再来一局吧!" << endl;
		        break;
		    } else {
		        spread(x, y);
		        if (checkWin()) {
		            cout << "你赢了!高手高高手!" << endl;
		            break;
		        }
		    }
		}
	}
	else if(x == 2)
	{
		bool f = 1;
		while(f = 1)
		{
			srand((unsigned)time(NULL));
			randomMine();
			while (true)
			{
				cout << "  0 1 2 3 4 5 6 7 8 9\n";
			    printMap();
			    char cx = '^',cy = '^';
			    cout << "请输入要打开的位置坐标(如0(x)1(y)),或输入-1结束游戏:" << endl;
			    cin >> cx >> cy;
			    
			    int x = cx - '0',y = cy - '0';
			    if(x == 12345666787878 && y == 45456663222)
			    {
			    	cout << "你赢了!高手高高手!" << endl;
			        break;
			    }
			    if (x == -1 || y == -1)
			    {
			        break;
			    }
			    if (mineMap[x][y] == 9)
			    {
			    	cout << "你输了,是否再试试有没有其他方法吧!(Yes/No):";
			    	string s;
			    	cin >> s;
			    	if(s != "Yes") 
			    	{
			        	return 1;
			    	}
			    }
			    else 
			    {
			        spread(x, y);
			    }
			}
		}
		return 1;
	}
}
void recursion()
{
	if(program() > -1)
	{
		cout << "是否继续(Yes/No):";
		string s;
		cin >> s;
		if(s == "Yes")
		{
			mineMap.assign(ROW, vector<int>(COL, 0));
			showMap.assign(ROW, vector<int>(COL, -1));
			recursion();
		}
	}
}
int main()
{
	long long B;
	int A;
	B=10000000000;
	for(int j=0;j<1;B=100000000000)
	{
		cout<<"请选择你想玩的游戏:"<<endl<<"1、趣味22题 2、石头剪刀布 3、计算小达人 4、计算器 5、牛人游戏 6、打字不要后悔 7、金币 8、无头小子照片 9、学霸才做的加法题 10、火影忍者 11、欢迎贵宾玩扫雷 12、英语回答问题 13、愤怒的皮皮 14、打字游戏 15、战争世界 16、双人五子棋 17、小伙见到一沓钱 18、计算(除法为整数除法,只要余数) 19、武将pk 20、猜数 21、死亡空格 22、循环诗 23、打印单位矩阵 24、计算 25、运算 26、打印数字金字塔 27、ASCII码查询(密码114666888)。如果不想玩了输入0 (注意:不要乱输入字符、21和22谨慎使用)<( ̄︶ ̄)↗[GO!]"<<endl;
	cin>>A;
	

	if(A==3)
		{
			clear();
			sleep(1);
	    srand(time(0)); 
    int tsum = 0;
    int maxt = 0;
    long long mint = 99999999999;
    int wrongCount = 0, rightCount = 0;
    for (int i = 1; i <= 10 ; i++)  //请写出循环条件
    {
       	long double a = rand() % 10 + 1;
        long double b = rand() % 10 + 1;
        long double op = rand() % 4 + 1;
        int res;
        if (op == 1) // 加法
        {
            cout << a << " + " << b << " = " << endl;
            res = a + b;
        }
        if (op == 2) // 减法
        {
            if (a < b)
            {
                int c = a;
                a = b;
                b = c;
            }
            cout << a << " - " << b << " = " << endl;
            res = a - b;
        }
        if (op == 3) // 乘法
        {
            cout << a << " * " << b << " = " << endl;
            res = a * b;
        }
        if (op == 4) // 除法
        {
            cout << a * b << " / " << a << " = " << endl;
            res = b;
        }
	    int ans, beg = time(0); // 开始时间
	    cout << "请输入你的计算结果:" << endl;
	    cin >> ans;
		if (ans == res)
        {
            cout << "(^-^)V 答对了!" << endl;
            rightCount++;
        }
        else
        {
            cout << "┭┮﹏┭┮ 答错了!" << endl;
            wrongCount++;
        }
        cout << endl; 
        int end = time(0); // 结束时间
		tsum += end - beg;
		if (end - beg > maxt)
		{
			maxt = end - beg;
		}
		if(mint>end-beg)
		{
			mint=end-beg;
		}
        cout << "本题用时:" << end - beg << " 秒" << endl << endl;
        sleep(1);
        clear();
        sleep(1);
    }
    cout << "( ̄▽ ̄)~* 游戏结束!" << endl;
	cout << "总计:" << rightCount * 10.0<< " 分" <<endl;
    cout << "对:" << rightCount << " 道" << endl;
    cout << "错:" << wrongCount << " 道" << endl;
    cout << "总用时:" << tsum << " 秒" << endl;
    cout << "平均用时:" << tsum / 10.0 << " 秒" << endl;
    cout << "最慢用时:" << maxt <<"秒"<< endl;
    cout << "最快用时:" << mint <<"秒"<< endl;
		}
	else if(A==2)	
	{
		int e1,u,h;
		cout<<"和垃圾版AI玩石头剪刀布,你想要几局几胜?"<<endl;
		cout<<"1、三局两胜 2、五局三胜 3、七局四胜";
		cin>>e1;
		if(e1==1)
		{
			e1=3;
		}
		else if(e1==2)
		{
			e1=5;
		}
		else if(e1==3)
		{
			e1=7;
		}
		else if(e1>3)
		{
		e1=3;
		}
		else
		{
			e1=7;
		}
	// 任务1 玩家出招
	for(int u=0;u<e1;u++)
	{
	cout << "和AI玩石头剪刀布,请输入你的选择:"<< endl;
	cout << "1、石头" << endl;
	cout << "2、剪刀" << endl;
	cout << "3、布" << endl;
	int a1;
	cin >> a1;
	if(a1>3)
	{
		a1=a1%3+1;
	}

	if(a1== 1)
	{
		cout << "你出的是石头" << endl;
	}
	if(a1== 2)
	{
		cout << "你出的是剪刀" << endl;
	}
	if(a1 == 3)
	{
		cout << "你出的是布" << endl;
	}
	// 任务2 AI出招
	srand(time(0)); //评测时请注释掉这行数据
	int b1 = rand()%3 +1;
	if(b1 == 1)
	{
		cout << "AI出的是石头" << endl;
	}
	if(b1== 2)
	{
		cout << "AI出的是剪刀" << endl;
	}
	if(b1 == 3)
	{
		cout << "AI出的是布" << endl;
	}
	// 任务3 判断胜负
	// 使用if嵌套来完成判断
	if(a1==b1)
	{
		cout<<"平手"<<endl;
	}
	else
	{
		if(a1<b1)
		{
			if(b1-a1==2)
			{
				h+=1;
				cout<<"你输了";
			}
			else
			{
				u+=1;
				cout<<"你赢了";
			}
		}
		else
		{
			if(a1-b1==2)
			{
				u+=1;
				cout<<"你赢了";
			}
			else
			{
				h+=1;
				cout<<"你输了";
			}
		}
	}
	}
	if(u>=h)
	{
		cout<<"总场结算:你赢了。";
	}
	else
	{
		cout<<"总场结算:你输了。";
	}
	}
	else if(A==1)
	{
	int a,b,c,d;
    long double e;//a是选择,b是做对题目数,c是想做的题目数,d是你想做的关卡;
    cout<<"请选择你想做的题目数:";
    cin>>c;
    b=0;
    for(int i=1;i<=c;i++)
    {
    	cout<<"第"<<i<<"次答题,请选择你想做的关卡(一共22题)";
    	cin>>d;
    	if(d>22)
    	d=d%22+1;
    	if(d==1)
    	{
    		cout<<"请问地球

标签:a%,游戏,int,t2,c++,else,time,分享,cout
From: https://blog.csdn.net/2401_88851881/article/details/143658951

相关文章

  • Visual C++ 6.0中文版安装包下载教程及win11安装教程
    本文分享的是VisualC++6.0(简称VC++6.0)中文版安装包下载及安装教程,关于win11系统下安装和使用VC++6.0使用问题解答,大家在安装使用的过程中会遇到不同的问题,如遇到解决不了的问题请给我留言!一、安装包的下载vc6.0安装包下载连接:https://pan.quark.cn/s/979dd8ba4f35二、......
  • C++零基础入门&趣味学信息学奥赛_开发环境安装
    Arduino软件安装,安装树莓派Pico开发板及上传Pico固件目录1.安装Windows驱动程序1.1.下载安装arduino软件:1.2.安装开发板Pico1.3.上传Arduino兼容的Pico固件1.安装Windows驱动程序                                        ......
  • C++ 移动构造和拷贝构造函数匹配
    既有拷贝构造又有移动构造这个比较好理解,普通的函数匹配规则就可以。右值移动,左值拷贝。——《C++Primer》P477我们不能隐式地将一个右值引用绑定到一个左值。有拷贝构造但没有移动构造这种情况,右值也会被拷贝。如果一个类没有移动构造函数,函数匹配规则保证该类型的对象......
  • C++继承和参数化类型(模板)各自的优点
    在C++中,继承和参数化类型(模板)都是强大的代码重用机制,它们各自具有独特的优点。以下是对这两种机制优点的比较和归纳:C++继承的优点代码重用:继承允许子类继承父类的属性和方法,从而避免了重复编写相同的代码。这不仅提高了开发效率,还减少了代码中的冗余。扩展性:通过继承,可以创建......
  • App中第三方登录和分享模块的实现
    @目录1流程2设计与实现3优化本文目的:“实现一套易于使用、维护的第三方登录和分享模块”我们开发App有时为了吸引用户,会引入三方的授权登录降低用户的注册和登录操作,同时会根据业务需求引入三方的分享服务。目前可用的第三方授权登录和分享有很多,国内比较常用的有微信、QQ、......
  • C++ 逆向之常用字符集互转
    在过往的编程过程中,常常会因为碰到字符集问题而头痛,而每次在进行字符集转换的时候,各种搜索网上文档,想找字符集转换的示例程序,但是都不尽人意,本篇文章的目的就是彻底解决之前编程过程中对字符集认识以及字符集转换之间似懂非懂、云里雾里的状态,并在文章结尾附上ANSI、UNICODE和U......
  • 《深度解析 C++中的弱引用(weak reference):打破循环依赖的利器》
    在C++编程的世界里,内存管理一直是一个关键且复杂的话题。而弱引用(weakreference)的出现,为我们处理一些特殊的内存相关问题提供了一种巧妙的方法。今天,我们就来深入了解一下什么是弱引用。一、从引用的基本概念说起我们都知道,在C++中,引用是一种给变量起别名的方式。正常......
  • 告别头文件,编译效率提升 42%!C++ Modules 实战解析 | 干货推荐
    编者按:AlibabaCloudLinux(简称“Alinux”)是目前阿里云上占比第一的操作系统。2021年,龙蜥以Alinux产品为基础发布了AnolisOS8正式版。本文中,阿里云智能集团开发工程师李泽政以Alinux为操作环境,讲解模块相比传统头文件有哪些优势,并通过若干个例子,学习如何组织一个C++模......
  • 洛谷P11228的C++题解
    题目分析题目题目让我们算出机器人走步后经过了多少个不重复的点这道题不是搜索!直接按照题意模拟就行了。遇到墙就向右转,不是就直行。特别注意:向右转也是一步!一个格子最多算一遍!我们可以用一个标记数组 st,走过的点就打上标记。判断走道的点有没有打上标记,有就不......
  • 修改 NIKKE PC 端游戏缓存位置
    本文记录如何使用mklink命令修改NIKKEPC端游戏缓存位置前言NIKKE每次版本更新都要下载大约5~10G的数据,以至于成为了我AFK的一部分原因[允悲]但是看游戏安装目录的大小却只有1G多,我还奇怪数据存哪去了,看到越来越小的C盘的空间才明白,草搜索了一下后立马mklink......