请问各位大佬最后的几个字符没有输出怎么办
查看原帖
请问各位大佬最后的几个字符没有输出怎么办
1600214
HY_ACM楼主2025/6/30 16:29
#include <iostream>

using namespace std;

int main()
{
	char str = 0, P = 0;
	
	while(cin >> str)
	{
		static int cnt = 0;
		
		if(str != P)
		{
			if(cnt) cout << cnt << P;	
				
			P = str;
			cnt = 1;
		}
		else
		{
			cnt++;
		}
	}
		
	return 0;
}
2025/6/30 16:29
加载中...