95求助,vs显示越界
查看原帖
95求助,vs显示越界
1593610
shiyizi楼主2024/12/25 20:57
#include <iostream>
#include <vector>
using namespace std;
struct person 
{
	int location;
	string career;
};
int main()
{
	int num, structure;
	cin >> num >> structure;
	vector<person> s(num);
	vector<vector<int>> a(structure,vector<int>(2));
	for (int i = 0; i < num; i++)
	{
		cin >> s[i].location >> s[i].career;
	}
	int current_location = 0;
	for (int i = 0; i < structure; i++)
	{
		cin >> a[i][0] >> a[i][1];
		if (a[i][0] == 0 )
		{
			if (s[current_location].location == 0)
			{
				current_location -= a[i][1];
			}
			else
			{
				current_location += a[i][1];
			}
		}
		else
		{
			if (s[current_location].location == 0)
			{
				current_location += a[i][1];
			}
			else
			{
				current_location -= a[i][1];
			}
		}
		if (current_location < 0)
		{
			current_location = current_location%num+num;
		}
		if (current_location > num-1)
		{
			current_location = current_location%(num-1)-1;
		}
	}
	cout << s[current_location].career << endl;
	return 0;
}
2024/12/25 20:57
加载中...