Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

输入应该是手动的,并且必须能够计算任何类型的输入的子字符串数并显示它们

  ask by Sanjana Ravichandran translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
145 views
Welcome To Ask or Share your Answers For Others

1 Answer

# Function to print all sub strings 
def subString(s, n): 
    # Pick starting point in outer loop 
    # and lengths of different strings for 
    # a given starting point
    c=0
    str=[]
    for i in range(n): 
        for len in range(i+1,n+1): 
            str.append(s[i: len]); 
            c+=1
    print("Number of substrings:",c)
    print("Substrings are :",", ".join(str))#prints substring

# Driver program to test above function 
s = "abcd"; 
subString(s,len(s)); 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...