字符串读入有误求助
查看原帖
字符串读入有误求助
323183
CLCK楼主2022/9/8 20:45
#include <iostream>
using namespace std;
struct man {
	int out;
}mn[100005];
string job[100005];
int n, m;
int npos;
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> mn[i].out;
		cin >> job[i];
	}
	npos = 1;
	while (m--) {
		int r; int num;
		cin >> r >> num;
		if (r == mn[npos].out) {
			npos += num;
			if (npos >= n) npos -= npos;
		}
		else {
			npos -= num;
			if (npos < 0) npos += npos;
		}
	}
	cout << job[npos] << endl;
	return 0;
}

rt

求助

一行中两个一起读 读入一个就出-1

小问题麻烦大佬解答 感激不尽

2022/9/8 20:45
加载中...