URL划分

  • s.find()函数可以直接返回位置
点击查看代码
#include <bits/stdc++.h>
using namespace std;
bool check(string s)
{
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='=')
		{
			return true;
		}
	}
	return false;
}
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		string s;
		cin>>s;
		int pos=s.find(':');
		cout<<s.substr(0,pos)<<endl;
		s.erase(0,pos+3);
		pos=s.find('/');
		cout<<s.substr(0,pos)<<endl;
		s.erase(0,pos+1);
		while(s.size())
		{
			int pos=s.find('/');
			string t=s.substr(0,pos);
			if(check(t))
			{
				cout<<t<<endl;
			}
			s.erase(0,pos+1);
		}
	}
	return 0;
}
posted @ 2024-07-23 12:20  D06  阅读(1)  评论(0编辑  收藏  举报