soal kuis ada NODE nya.docx

Embed Size (px)

Citation preview

  • 7/21/2019 soal kuis ada NODE nya.docx

    1/1

    Int count(string)

    Char *string;

    {/* This module is incorrect. Its specification is:

    If string begins with A (eg ABXCCZBZ) then

    return the number of occurences of C (eg 2),

    * otherwise return -1.

    */

    Int index = 0, I =0, j = 0, k = 0; 1

    2 If (string*index+ == A)

    L1: index = index +1; 3

    If (string*index+ == B) 4

    J = j + 1;

    K = 0; 5

    Goto L1; 6

    }

    If (string*index+ == C)7

    I = I + j;

    K = k + 1;

    J = 0; 8

    Goto L1; 9

    }

    I = I + j; 10

    If (string*index+ != \0) 11

    J = 0; 12

    Goto L1; 13

    }

    } else

    I = -1; 14

    Return I; 15

    }