Why doesn't this work?

by (Login Tusike)

 

6 people go to the movies, and they 6 tickets for seats that are in one row. AB want to sit next to each other, CD don't. How many ways can they sit down? :

DIM names(1 TO 6)
CLS
count = 0
FOR i = 1 TO 6
names(i) = i + 64
NEXT
FOR a = 1 TO 6
FOR b = 1 TO 6
IF b <> a THEN
FOR c = 1 TO 6
IF c <> a AND c <> b THEN
FOR d = 1 TO 6
IF d <> a AND d <> b AND d <> c THEN
FOR e = 1 TO 6
IF e <> a AND e <> b AND e <> c AND e <> d THEN
FOR f = 1 TO 6
IF f <> a AND f <> b AND f <> c AND f <> d AND f <> e THEN
text$ = CHR$(a + 64) + CHR$(b + 64) + CHR$(c + 64) + CHR$(d + 64) + CHR$(e + 64) + CHR$(f + 64)
GOSUB analyse

END IF
NEXT
END IF
NEXT
END IF
NEXT
END IF
NEXT
END IF
NEXT
NEXT

PRINT count: END
analyse:
ABright = 0
FOR x = 1 TO 5
IF RIGHT$(LEFT$(text$, x), 1) = "A" AND RIGHT$(LEFT$(text$, x + 1), 1) = "B" THEN ABright = 1: GOTO 1
IF RIGHT$(LEFT$(text$, x), 1) = "B" AND RIGHT$(LEFT$(text$, x + 1), 1) = "A" THEN ABright = 1: GOTO 1
NEXT
1
CDright = 0
FOR x = 1 TO 5
IF RIGHT$(LEFT$(text$, x), 1) = "C" AND RIGHT$(LEFT$(text$, x + 1), 1) = "D" THEN CDright = 1: GOTO 2
IF RIGHT$(LEFT$(text$, x), 1) = "D" AND RIGHT$(LEFT$(text$, x + 1), 1) = "C" THEN CDright = 1: GOTO 2
NEXT
2
IF ABright = 1 AND CDright = 0 THEN count = count + 1: COLOR 9: PRINT text$: 'SLEEP 1
RETURN

Posted on Jan 2, 2008, 9:43 AM

Respond to this message   

Return to Index

Response TitleAuthor and Date
Found the problem on Jan 2
i dunnomennonite on Jan 2
Why didn't Tusike's program compile? A bug in QB64... on Jan 2
 a list of things i noticed about 0.40mennonite on Jan 2
  RE: a list of things i noticed about 0.40 on Jan 3
   *looking forward to 0.5xmennonite on Jan 3
   oh and print!mennonite on Jan 3
    Yes, I've already fixed the backslash issue for Demo #5 on Jan 3
     *yay for demo 5 (i know it means something in other languages)mennonite on Jan 3
 Hrm... on Jan 2
  shouldn't that be bitand? on Jan 2
   *i'm not sure that qbasic and is.mennonite on Jan 2
    Re: *i'm not sure that qbasic and is. on Jan 2
     Yep! That's right!rpgfan3233 on Jan 4
      *(URL) on Jan 5
   QBASIC's AND on Jan 2
    Re: QBASIC's AND on Jan 2
     I realized later.... on Jan 4

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement