为什么报错了?
  • 板块灌水区
  • 楼主szm111213
  • 当前回复9
  • 已保存回复9
  • 发布时间2024/9/10 21:53
  • 上次更新2024/9/11 15:15:44
查看原帖
为什么报错了?
1066396
szm111213楼主2024/9/10 21:53

帮帮我,为什么出错了

[Error] no matching function for call to 'stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'

它写的第11行有问题

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin >> a;
	for(int i = 0;i<a.size();i++)
	{
		if(a[i] >= '1' && a[i] <= '9')
		{
			int num = stoi(a[i]);
			string s = a.substr(0,i);
			for(int j=1;j<=num;j++)
			{
				a.insert(i,1,s);
			}
		}
	}
	cout << a << endl;
	return 0;
}

2024/9/10 21:53
加载中...