随机分位系统破解版 (BPS)Version-B4.2

支持在分位前先绑定一对或多对同学

具体操作方法请见代码开头注释

《原创,未经许可请勿转载!》

原版代码 #【戳我】#

cpp 复制代码
/*
## Sunshine Position System 破解版 ##
		   @绑定座位@ 
		 -version B4.2- 
		 
%操作方法% 
在90行输入要绑定的两个学生的下标
在91行修改绑定学生的对数 (默认0)
 
*/ 


#include<windows.h>
#include<bits/stdc++.h>
#include<cmath>
#include<ctime>
#include<fstream>
#define This_program_is_writing_by_WTC
#define Sunshine_Positioning_System
//定义所需头文件 

using namespace std;

int h=6,l=8;//定义座位表布局 

bool seat[10][10];//判断此座位是否被占用 

bool stu[100];//判断该学生是否已经分配座位 

string name[100]={//定义学生名单 
" error  ",//不存在编号为0的学生 
" aaa ",//1
" bbb ",//2
" ccc ",//3
" ddd ",//4
};

string s[10][10];//定义座位表数组 

void slowout(string nr)//慢速输出文字 
{
    int sz=nr.length();
    for(int i=0;i<sz;i++)
    {
        cout<<nr[i];
        Sleep(1);
    }
}

string setname(string a)//输入处理
{
    string chulia; 
    for(int i=0;i<a.size()-1;i++)
    {
        if(a[i]!=' ')//去除空格 
        {
            chulia+=a[i];
        }
    }
    return chulia;
}

string nameadd(string adds)//添加空格 
{
    int padding=0;
    if(adds.length()==4) padding=2;
    else if(adds.length()==6) padding=1;
    adds.insert(0, padding, ' ');
    adds.append(padding, ' ');
    return adds;
}

int findxy(string what)//寻找学生下标 
{
    int leng=50;
    for(int i=1;i<=leng;i++)
    {
        if(name[i]==what)//如果找到即返回下标 
        {
            return i;
        }
    }
    return 0;//没有找到即返回0 
}

//---
struct BLACK
{
	int stuone,stutwo;
}black[30]={1,2};
int bl=0;
//---

// 定义导出到文件的函数
void exportToFile(string seatTable[10][10], int rows, int cols) {
    ofstream outFile("zwb.txt"); // 创建并打开文件 zwb.txt

    if (outFile.is_open()) {
        // 写入表头
        outFile << "行\\列|    1   |    2   |    3   |    4   |    5   |    6   |    7   |    8   |" << endl << endl;

        // 循环写入每一行的内容
        for (int i = 1; i <= rows; i++) {
            outFile << "|  " << i << " |";
            for (int j = 1; j <= cols; j++) {
                outFile << seatTable[i][j] << "|";
            }
            outFile << endl << endl;
        }

        outFile.close(); // 关闭文件
    }
}



struct Students_with_reserved_seats
{
    int posx=0,posy=0;
    int pos_stu=0;
}t[15];

int main()

{
    
    system("cls");//清空屏幕 
    system("title Sunshine Positioning System---By WTC");//设置窗口标题 
    srand(time(0));//防止生成伪随机数 
    stu[99]=true;//使第一次生成时进入循环 
    
    //生成前内容部分 
    slowout("阳光分位系统(Sunshine Positioning System)  ------By WTC");
    Sleep(345);
    cout<<endl;
    slowout("请按任意键继续. . .");
    system("cls");
    cout<<"阳光分位系统(Sunshine Positioning System)  ------By WTC";
    cout<<endl;
    system("pause");
    system("cls");
    
    int num=0,count=0;
    slowout("请输入定点位置的学生个数:"); 
    cin>>num;
    while(count<num)
    {
        count++;
        cout<<"\n\n";
        slowout(" Case #");
        Sleep(1);
        cout<<count;
        Sleep(1);
        cout<<endl;
        string posnam,posname;
        slowout("请输入需要固定位置的学生名:");
        cin>>posnam;
        posname=nameadd(posnam);
        t[count].pos_stu=findxy(posname);
        if(findxy(posname)==0)
        {
            slowout("没有找到该学生!");
            Sleep(567);
            count--;
            continue;
        }
        slowout("请输入该学生的位置:(行 列)");
        cin>>t[count].posx>>t[count].posy;
        if(t[count].posx<1||t[count].posx>h||t[count].posy<1||t[count].posy>l)
        {
            slowout("没有该位置!");
            Sleep(567);
            count--;
            continue;
        }
        seat[t[count].posx][t[count].posy]=true;
        stu[t[count].pos_stu]=true;
    }

    //开始随机分配座位 
    slowout("座位表已生成:");
    cout<<endl;
    slowout("行\\列|    1   |    2   |    3   |    4   |    5   |    6   |    7   |    8   |");
    Sleep(1);
    cout<<endl<<endl;
    for(int i=1;i<=h;i++)
    {
        cout<<"|";
        Sleep(1);
        cout<<" ";
        Sleep(1);
        cout<<" ";
        Sleep(1);
        cout<<i;
        Sleep(1);
        cout<<" ";
        Sleep(1);
        cout<<"|";
        Sleep(1);
        for(int j=1;j<=l;j++)
        {
        	if(s[i][j]!="")
        	{
//        		slowout(s[i][j]);
//        		Sleep(1);
//            	cout<<"|";
//            	continue;
				continue;
			}
            Sleep(1);
            bool isReserved = false;
            for(int k=1;k<=num;k++)
            {
                if(i==t[k].posx&&j==t[k].posy)
                {
                    slowout(name[t[k].pos_stu]);
                    s[i][j] = name[t[k].pos_stu];  // 记录固定座位的学生
                    Sleep(1);
                    cout<<"|";
                    isReserved = true;
                    break;  // 找到后退出内层循环
                }
            }
            if (isReserved) {
                continue;  // 如果是固定座位,跳过随机分配
            }
            
            // 处理随机分配的座位
            int st=0;
            while(stu[st]==true||name[st]==""||name[st]==" error  ")
            {//如果生成了不在区间内的随机数或该学生已经分配座位,则重新生成 
                st=rand()%50+1;//生成随机数 
            }
            
            slowout(name[st]);//输出学生姓名 
            stu[st]=true;//标记该学生已分配到座位 
            s[i][j]=name[st];//记录该座位学生 
            Sleep(1);
            cout<<"|";
            for(int c=0;c<bl;c++)
            {
            	if(black[c].stuone==st&&stu[black[c].stutwo]==false)
            	{
            		if(j!=l)
					{
						s[i][j+1]=name[black[c].stutwo];
						slowout(name[black[c].stutwo]); 
						Sleep(1);
	            		cout<<"|";
					}
					else
					{
						s[i+1][j]=name[black[c].stutwo];
					}
	            	stu[black[c].stutwo]=true;
				}
				else if(black[c].stutwo==st&&stu[black[c].stuone]==false)
            	{
            		if(j!=l)
					{
						s[i][j+1]=name[black[c].stuone];
						slowout(name[black[c].stuone]); 
						Sleep(1);
	            		cout<<"|";
					}
					else
					{
						s[i+1][j]=name[black[c].stuone];
					}
	            	stu[black[c].stuone]=true;
				}
			}
        }
        Sleep(99);
        cout<<endl<<endl;
    }
    
    //调换座位部分 
    slowout("生成完毕,输入坐标(行 列)调换座位:");
    cout<<endl;
    
    int x,y,a,b;
    while(true) 
    {
        //输出提示内容 
        cout<<endl;
        slowout("请输入需要调换的两个座位: ");
        Sleep(1);
        cout<<endl;
        slowout("示例:");
        Sleep(1);
        cout<<endl;
        slowout("________________________________________");
        Sleep(1);
        cout<<endl;
        slowout("如1行1列为");
        cout<<s[1][1];
        Sleep(1);
        cout<<endl;
        slowout("2排2列为");
        cout<<s[2][2];
        Sleep(1);
        cout<<endl;
        slowout("如需调换二人座位,则在S1输入:1 1 ,S2输入 2 2 。");
        Sleep(1);
        cout<<endl;
        slowout("如需终止程序,请在S1第一个数输入0。");
        Sleep(1);
        cout<<endl;
        slowout("----------------------------------------");
        Sleep(1);
        cout<<endl;
        slowout(" S1 = ");
        cin>>x>>y;//请求S1坐标 
        if(x==0) break;//x为0,则结束程序 
        else if(x<1||x>h||y<1||y>l)//判断x,y是否为合理值 
        {
            slowout("无效输入!");
            Sleep(123);
            system("cls");//如果是,则要求重新输入 
        }
        else
        {
            cout<<endl;
            slowout(" S2 = ");
            cin>>a>>b;//请求S2坐标 
            if(a<1||a>h||b<1||b>l) //判断x,y是否为合理值 
            {
                slowout("无效输入!");
                Sleep(123);
                system("cls");//如果是,则要求重新输入 
            }
            else
            {
                swap(s[x][y],s[a][b]);//交换S1与S2 
                slowout("已完成:");
                cout<<s[a][b]<<"与"<<s[x][y];
                slowout("的调换!");
                Sleep(2345);
                system("cls");
                slowout("调换后座位表:"); 
            }
        }
        
        //输出调换后座位表
        cout<<"\n行\\列|    1   |    2   |    3   |    4   |    5   |    6   |    7   |    8   |\n"; 
        for(int i=1;i<=h;i++) 
        {
            cout<<"\n|  "<<i<<" |";
            for(int j=1;j<=l;j++)
            {
                cout<<s[i][j];
                cout<<"|";
            }
            cout<<endl;
        }
    }
    
    //调用函数将生成的座位表导出到文件
    exportToFile(s, h, l);
    slowout("座位表已成功导出到 zwb.txt 文件!");
    cout<<endl;
    Sleep(1);
    cout<<endl;
    slowout("程序已结束。");//结束语 
    return 10086;
    
}

/*
版本: Version B - 4 . 2 
更新日志:
------------------------------------
①2025/9/23 完成随机分位主体内容 
②2025/9/24 优化内容显示、增加调换位置功能 
③2025/9/25 优化内容显示、增加代码注释
④2025/9/26 增加学生绑定功能、优化内容显示、增加座位表导出到文件功能
⑤2025/10/26 去除学生绑定功能、简化代码、增加定点位置功能
⑥2025/11/3 修复定点位置功能的已知BUG 
⑦2025/05/19 更新破解版 
*/
相关推荐
paeamecium3 小时前
【PAT甲级真题】- Kuchiguse (20)
数据结构·c++·python·算法·pat考试·pat
txzrxz3 小时前
拓补排序讲解
c++·算法·图论·排序
小保CPP4 小时前
OpenCV C++基于模糊数学的图像滤波
c++·人工智能·opencv·计算机视觉
明日清晨5 小时前
VS2022禁用 NRVO/返回值优化(不调用拷贝构造函数处理方式)
c++
阿米亚波5 小时前
【C++ STL】std::array
java·开发语言·c++
choumin5 小时前
结构型模式——组合模式
c++·设计模式·组合模式·结构型模式
努力努力再努力wz5 小时前
【分布式系统与 RPC 框架系列】从单机瓶颈到远程调用:一文理解分布式架构与 RPC 原理
linux·网络·c++·分布式·网络协议·rpc·架构
神仙别闹6 小时前
基于C++实现(控制台)景区旅游管理系统
开发语言·c++·旅游
hold?fish:palm17 小时前
kv存储主从复制的设计与实现
c++·redis·后端