# 題目: UVa 10800 - Not That Kind of Graph

# 題目說明

給一個由RFC組成的字串,使用/\_畫出圖表

  1. R : 上升一格
  2. F : 下降一格
  3. C : 維持同一格

INPUT:
輸入一個整數T,代表測資數
每筆測資輸入一個字串


OUTPUT:
使用/\_畫出的圖表

# 解題方法

先計算此圖表的最大高度,存入變數len
宣告一個二維陣列,將中點設為len,上下各擁有len個空間,長度則是輸入的字串長度+1
接著處理輸入字串的符號,在對應位置填入/\_
最後再按照格式輸出

# 參考程式碼

#include <iostream>
#include <string>
#include <vector>

using namespace std;

static auto fast_io = []
{
	ios::sync_with_stdio(false);
	cout.tie(nullptr);
	cin.tie(nullptr);
	return 0;
}();

int main()
{
	int T, cnt = 0;
	string str;

	cin >> T;

	while (T--)
	{
		cin >> str;

		int len = 0, tmp = 0;
		for (auto& c : str)
		{
			if (c == 'R') ++tmp;
			else if (c == 'F') --tmp;
			len = max(len, max(tmp, -tmp));
		}

		vector<vector<char>> V(len * 2 + 1, vector<char>(str.size() + 1, ' '));

		int x = len, y = 0;
		for (auto& c : str)
		{
			if (c == 'R') V[x++][y++] = '/';
			else if (c == 'F') V[--x][y++] = '\\';
			else V[x][y++] = '_';
		}

		cout << "Case #" << ++cnt << ":\n";
		for (int i = V.size() - 1; i >= 0; --i)
		{
			while (!V[i].empty())
			{
				if (V[i].back() == ' ') V[i].pop_back();
				else break;
			}
			if (!V[i].empty())
			{
				cout << "| ";
				for (auto& j : V[i]) cout << j;
				cout << "\n";
			}
		}
		cout << "+";
		for (int i = 0; i < str.size() + 2; ++i) cout << '-';
		cout << "\n\n";
	}
}