REM Andrea Liu REM Division:Intermediate REM Contest: #2 REM School: Freehold H.S. REM School Code: 9001 REM State: NJ REM Name of Program: INT_C2_AL.bas REM Advisor: Mr. Gill REM Year: 2007-2008 REM Language: Basic CLS 10 tenp$ = "" PRINT PRINT LINE INPUT "Enter the string. ", x$ y = LEN(x$) REDIM words$(1 TO y) REDIM punc$(1 TO y) REDIM flags(1 TO y) REDIM flags2(1 TO y) REDIM flags$(1 TO y) REDIM flags2$(1 TO y) FOR z = 1 TO y t$ = MID$(x$, z, 1) IF t$ = " " THEN t$ = "" ascii = 70 ELSEIF t$ <> " " THEN ascii = ASC(t$) END IF IF t$ = "'" THEN ascii = 70 temp$ = temp$ + t$ IF t$ = "" THEN true = 0 FOR u = 1 TO y IF words$(u) = temp$ THEN flags(u) = flags(u) + 1 true = 1 temp$ = "" END IF NEXT IF true = 0 THEN words$(z) = temp$ flags(z) = 1 temp$ = "" END IF END IF IF ascii > 90 OR ascii < 65 THEN t2 = LEN(temp$) - 1 temp2$ = RIGHT$(temp$, 1) temp$ = LEFT$(temp$, t2) true = 0 true2 = 0 FOR u = 1 TO y IF words$(u) = temp$ THEN flags(u) = flags(u) + 1 true = 1 temp$ = "" END IF IF punc$(u) = temp2$ THEN flags2(u) = flags2(u) + 1 true2 = 1 temp2$ = "" END IF NEXT IF true = 0 THEN words$(z) = temp$ flags(z) = 1 temp$ = "" END IF IF true2 = 0 THEN punc$(z) = temp2$ flags2(z) = 1 temp2$ = "" END IF END IF NEXT output$ = "" FOR o = 1 TO y IF words$(o) <> "" THEN flags$(o) = STR$(flags(o)) flags$(o) = RIGHT$(flags$(o), 1) output$ = output$ + flags$(o) output$ = output$ + words$(o) END IF NEXT FOR j = 1 TO y IF punc$(j) <> "" THEN flags2$(j) = STR$(flags2(j)) flags2$(j) = RIGHT$(flags2$(j), 1) output$ = output$ + flags2$(j) output$ = output$ + punc$(j) END IF NEXT PRINT output$ PRINT PRINT INPUT "1 to continue, 0 to end. ", fin IF fin = 1 THEN GOTO 10 END