字符串对比基础练习:判断字符串间关系.pdfVIP

  • 0
  • 0
  • 约1.59千字
  • 约 4页
  • 2026-02-05 发布于北京
  • 举报

字符串对比基础练习:判断字符串间关系.pdf

基础练习字符串对比

时间限制:1.0s内存限制:512.0MB

问题描述

给定两个仅由大写字母或小写字母组成的字符串(长度介于1到10之间),

它们之间的关系是以下4中情况之一:

1:两个字符串长度不等。比如Beijing和Hebei

2:两个字符串不仅长度相等,而且相应位置上的字符完全一致(区分大小

写),比如Beijing和Beijing

3:两个字符串长度相等,相应位置上的字符仅在不区分大小写的前提下才

能达到完全一致(也就是说,它并不满足情况2)。比如beijing和BEIjing

4:两个字符串长度相等,但是即使是不区分大小写也不能使这两个字符串

一致。比如Beijing和Nanjing

编程判断输入的两个字符串之间的关系属于这四类中的哪一类,给出所属的

类的编号。

输入格式

包括两行,每行都是一个字符串

输出格式

仅有一个数字,表明这两个字符串的关系编号

样例输入

BEIjing

beiJing

样例输出

3

BasicPracticeStringComparison

TimeLimit:1.0sMemoryLimit:512.0MB

问题描述

Giventwostringsconsistingonlyofuppercaseorlowercaseletters(length

ween1and10),theirrelationshipfallsintooneofthefollowing4cases:

1:Thetwostringshavedifferentlengths.Forexample,BeijingandHebei

2:Thetwostringsnotonlyhavethesamelength,butalsothecharactersatcorres

pondingpositionsareexactlythesame(case-sensitive),suchasBeijingandBeijing

3:Thetwostringshavethesamelength,andthecharactersatcorrespondingpositionsareidenticalonly

whencaseisignored(thatis,itdoesnotmeetcondition2).Forexample,beijingandBEIjing

4:Thetwostringshavethesamelength,butevenwhencaseisignored,these

twostringscannotbemadeidentical.Forexample,BeijingandNanjing.

Determinetherelationshipweenthetwoinputstringsandidentifywhichof

thefourcategoriestheybelongto,providingthenumberofthecategory.

输入格式

Consistsoftwolines,eachlinebeingastring.

输出格式

Thereisonlyonenumber,indicatingthe

relationshipnumberweenthesetwostrings.

Sampleinput:BEIjingbeiJing

Sample

output:3

文档评论(0)

1亿VIP精品文档

相关文档