• 2022-06-12
    设计一个算法Strcmp(s,t),以字典顺序比较两个英文字母串s和t的大小,假设两个串均以顺序串存储。例如:"ab" <; "abcd""abcd" <; "abd"
  • int Strcmp(SqString s,SqString t){ int i,comlen; if (s.length<;t.length)comlen=s.length;//求s和t的共同长度 elsecomlen=t.length; for (i=0;i<;comlen;i++)//在共同长度内逐个字符比较if (s.data[i]>;t.data[i])return 1;else if (s.data[i]<;t.data[i])return -1; if (s.length==t.length)//s==treturn 0; else if (s.length>;t.length)//s>;treturn 1; else return -1;//s<;t}[/i][/i][/i][/i]

    内容

    • 0

      设有两个字符串s和t,判断t是否为s子串的算法称为()。 A: 求子串 B: 求子串 C: 串匹配 D: 求串长

    • 1

      设有两个串T和S,其中T是S的子串,则求T在S中首次出现位置的算法称为( )。 A: 求子串 B: 求串长 C: 模式匹配 D: 串联接

    • 2

      设有两个串T和S,其中T是S的子串,则求T在S中首次出现位置的算法称为()。

    • 3

      设有两个串s和t,判断t是否为子串的算法称为() A: 求子申 B: 串连接 C: 串匹配 D: 求串长

    • 4

      写算法,实现顺序串的基本操作StrReplace(&s,t,v)。