请问各位大佬,题意看不太懂,30分
查看原帖
请问各位大佬,题意看不太懂,30分
921649
ArcWinz楼主2023/1/11 00:11

主要看了题解之后,发现都有将字符类型转换为整型,请问这一步的用意是什么,字符型和整型的输出结果看起来不是一样的吗

#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

int main()
{
	string input;
	cin >> input;
	
	int pos1 = input.find("a:=");
	int pos2 = input.find("b:=");
	int pos3 = input.find("c:=");
	
	string a = "0", b = "0", c = "0";
	
	if (pos1 != string::npos)
	{
		if (input[pos1+3] == 'b')
			a = b;
		else if (input[pos1+3] == 'c')
			a = c;
		else
			a = input[pos1 + 3];
	}
		
	if (pos2 != string::npos)
	{
		if (input[pos2+3] == 'a')
			b = a;
		else if (input[pos2+3] == 'c')
			b = c;
		else	
			b = input[pos2 + 3];
			
	}
		
	if (pos3 != string::npos)
	{
		if (input[pos3+3] == 'a')
			c = a;
		else if (input[pos3+3] == 'b')
			c = b;
		else
			c = input[pos3 + 3];
	}	
		
	cout << a << " " << b << " " << c;
	
	return 0;
}
2023/1/11 00:11
加载中...