字符串的展开


S a m p l e Sample Sample I n p u t Input Input#1
1 2 1
abcs-w1234-9s-4zz
S a m p l e Sample Sample I n p u t Input Input#2
2 3 2
a-d-d
S a m p l e Sample Sample I n p u t Input Input#3
3 4 2
di-jkstra2-6
S a m p l e Sample Sample O u t p u t Output Output#1
abcsttuuvvw1234556677889s-4zz
S a m p l e Sample Sample O u t p u t Output Output#2
aCCCBBBd-d
S a m p l e Sample Sample O u t p u t Output Output#3
dijkstra2************6

H i n t Hint Hint

T r a i n Train Train o f of of T h o u g h t Thought Thought

大模拟

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char c, sx, sy, si, sj;
int x, y, z;
string s;
bool b;
int main()
{
//	freopen("1.out","w",stdout);
	scanf("%d%d%d", &x, &y, &z);
	cin>>sx;b = 0;
	while(cin>>c)
	{
		if(c == '-' && sx != '-')//特判减号有一边也是减号
		{
			sy = ' ';//判断是否读完
			cin>>sy;
			if(!b)cout<<sx;//若它未输出过
			if(sy == ' ')cout<<'-';//判断是否读完
			else if(sx == sy || sx > sy || (sx <= '9' && sy >= 'A')//特判字母/数字相同或左边大于右边
			|| (sy <= '9' && sx >= 'A') || (sx <= 'Z' && sy >='a')//特判两边的类型不同
			|| (sy <= 'Z' && sx >='a')){cout<<c<<sy;sx = sy;b = 1;}
			else if(sx + 1 == sy){cout<<sy;sx = sy;b = 1;}//特判两个字母/数字是连续的
			else
			{
				si = sx, sj = sy;
				if(x == 1)if(sx >= 'A' && sx <= 'Z')si = sx + 32, sj = sy + 32;//小写字母
				if(x == 2)if(sx >= 'a' && sx <= 'z')si = sx - 32, sj = sy - 32;//大写字母
				if(x == 3)
				{
					for(int i = 1; i <= (sy - sx - 1) * y; i++)
						cout<<'*';//星号
				}
				else if(z == 1)
				{
					for(int i = 1; i <= sy - sx - 1; i++)
						for(int j = 1; j <= y; j++)
							cout<<(char)(si + i);//正序输出
				}
				else if(z == 2)
				{
					for(int i = 1; i <= sy - sx - 1; i++)
						for(int j = 1; j <= y; j++)
							cout<<(char)(sj - i);//倒叙输出
				}
				cout<<sy;
				sx = sy;//防止此字母后面还是个减号
				b = 1;
			}
		}
		else
		{
			if(sx != ' ' && !b)cout<<sx;
			sx = c;
			b = 0;
		}
	}
	if(sx != ' ' && !b)cout<<sx;
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值