sdut1916 字符串扩展

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[1005];
int main(){
	int t;
	int len;
	int i,j;
	scanf("%d",&t);
	getchar();
	while(t--){
		gets(a);
		len=strlen(a);
		printf("%c",a[0]);
		for(i=1;i<len;i++){
			if(a[i]=='-'&&a[i-1]<=a[i+1]&&((a[i-1]>='a'&&a[i-1]<='z'&&a[i+1]>='a'&&a[i+1]<='z')||(a[i-1]>='A'&&a[i-1]<='Z'&&a[i+1]>='A'&&a[i+1]<='Z')||(a[i-1]>='0'&&a[i-1]<='9'&&a[i+1]>='0'&&a[i+1]<='9'))){
				for(j=a[i-1]+1;j<=a[i+1]-1;j++)
					printf("%c",j);
			}
			else
				printf("%c",a[i]);
		}
		printf("\n");
	}
	return 0;
} 



/**************************************
	Problem id	: SDUT OJ 1916 
	Result		: Accepted 
	Take Memory	: 452K 
	Take Time	: 0MS 
	Submit Time	: 2013-05-26 17:44:53  
**************************************/

SDUT 是山东理工大学(Shandong University of Technology)的缩写,这里我假设你是在问关于 Python 字符串的问题。 Python 中的字符串是一种不可变的序列类型,用于表示 Unicode 字符序列。Python 字符串可以用单引号、双引号或三引号括起来,三引号可以用于表示多行字符串。例如: ```python s1 = 'Hello, world!' s2 = "Hello, world!" s3 = '''Hello, world!''' ``` 如果你需要在字符串中使用单引号或双引号,可以使用另一种引号来括起来字符串,例如: ```python s4 = "I'm a student." s5 = 'He said, "Hello, world!"' ``` Python 提供了一些内置的字符串方法,例如: - `str.lower()`:返回字符串的小写形式。 - `str.upper()`:返回字符串的大写形式。 - `str.strip([chars])`:移除字符串开头或结尾的指定字符,默认移除空格符。 - `str.split([sep[, maxsplit]])`:使用指定的分隔符将字符串分割为子字符串。 - `str.join(iterable)`:使用字符串将可迭代对象中的元素连接起来。 - `str.replace(old, new[, count])`:返回将字符串中指定子字符串替换为新字符串后的副本。 例如: ```python s = ' Hello, world! ' s = s.strip() # 移除开头和结尾的空格符 print(s.lower()) # 输出:hello, world! print(s.upper()) # 输出:HELLO, WORLD! print(s.split(',')) # 输出:['Hello', ' world!'] print('-'.join(s.split(','))) # 输出:Hello- world! print(s.replace('world', 'Python')) # 输出:Hello, Python! ``` 希望这些信息对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值