-













































: Qbasic

: Qbasic

Qbasic

QBASIC (Beginner's All-purpose Instruction Code) , , 1960 .

QBASIC . , QBASIC , - .

QBASIC ( ):

n ;

n ;

n , , , ..)

QBASIC , : (Shift +F5).

Š

, , , (, ; : " ' ?) , (* / - + < > <= >= = <> .), (% & ! # $ ).

.

, , .

, : 0, - 17, 0.25, - 34.85.

- . , , , , . +, -, *, /, ^.

:

1) - ^

2) , *, /

3) , +, -

. , . .

:

ABS ( ) - ½ ½

SQR ( ) - ( Ö` ).

INT ( ) -

SIN ( ) - ( )

COS ( ) -

TAN ( x ) -

ATN ( x ) -

LOG ( x ) -

EXP ( x ) -

SGN (x) -

.

1) X2 +2X-5.12 (X^2+2*X-5.12)/(X^2+12.51)

X2+12.51

2) COS(X) - SIN(X) (COS(X)-SIN(X))/(ABS(COS(X)+SIN(X)))

| COS(X) + SIN(X)|

1. , .

) ՠ ) 1 ) ¢ ) 12 ) AB ) ABCD

) SIN ) SIN ( ) ) -1 ) 2 ) MAX15

2. :

2 + Y2

1+ 2- Y2

2

 

- 2,5

 
 


 
 
 
) ) 1+ + 2 ) 1+ ½½+ ½1+½ ) + 2 C+D

+ 30,2

 

C+D

 
) A+B -1,7 ) __1,2-9,8____ ) Ö 2 + Y2 +100

1-Y(54,264-) (2+50,2)

E+F+0,5

3. , , :

) +B/ (C+D) - ( A+B) / C+D ) A*B/ (C+D) - (C - D)/ B*(A+B)

) 1+SQR (COS (+Y)/ 2) ) 2.56 + S ( ^2-Y^6)

) INT (*5.234 - *(+Y))

-

I :

|

ç

, . , , , , .

۠ 1. =0 2. =2 3. =2 : =3

= (+)^ 2/5

1. :

) =  ) *+B=C ) Z=Z+1 ) Y=Y e) - Y=Y

2. :

) Z ,

Y.

) ,

) 0.1,

) Y.

3. :

) , - Y.

) Y, 0.

4) , Y ½½-½Y ½ X=2,57 Y=-5,379

1+½*Y½

-

:

INPUT ["";] X1, [X2, X3... XN]

[ ] - , , ;

X1, X2, ... XN - .

, X1, X2, ... XN .

READ X1,X2,X3, ... XN X1,X2,..XN -

DATA C1, C2, C3, ... CN C1, C2, ... CN -

X1 C1, X2 C2...

! DATA . DATA READ.

RESTORE .

PRINT S1[ ;S2; S3 ...]

S1, S2 ... SN -

:

1) , ;

2) , ;

3) , .

:

1) , - , 8 ;

2) ; - .

:

LOCATE X,Y

X - 1<=X<= 24 , Y - 1<=Y<= 80.

.

:

1) Y=, =. :

  =Y =X

2) Y=, 堠 =- 5.25, =, =

: Y=Y

2

===

3) Y=, =Sin,

:

Y=Y

2

 =

4) Y = (723,3/200,2)2 , Z=(53.2/41.3)3

:

Y=Y

2

X=X Z=Z

5)Y=, X=Sin2 |Z|+0.5Z ; A=2CosZ+1/(SinZ+2), Z

:

Y=Y

X=X A=A

6)Y=Cos, Z=Sin ,X*

Y=Y Z=Z 10- 12- .

7) ,. , , , :

)322-22-72-42+15+22-3+10+6

)1-2+32-43 )1+2+32+43 )24-32+42-5+6

.

- , .

- , .(. .)

= = AND "" ()
< OR "" ()
> NOT "" ()
<= <=
>= >=
<> <> 

( ), a b - .

A B NOT a NOT b a AND b a OR b
TRUE TRUE FALSE FALSE TRUE TRUE
TRUE FALSE FALSE TRUE FALSE TRUE
FALSE TRUE TRUE FALSE FALSE TRUE
FALSE FALSE TRUE TRUE FALSE FALSE

: a + b > c AND d <> 8 .

NOT () : NOT ( a> b )

: TRUE () FALSE (). .

:

, ,

:

( X>0 ) (Y<0 ) ( X>0 ) AND (Y<0 )
-2<= X <=2 (X>=-2 ) AND (Y<= 2 )
X<0 X>10 ( X<0 ) OR (X>10 )

:

n ;

n NOT ;

n AND, /, * ;

n OR, +, - ;

n .

1.

) 2 -2 <=12 =0 =-1 ) NOT ((X*Y) OR (Y >X) X=4, Y=1

2. , :

) X>0 Y>0 Y MAX (X, Y, Z)

) , X>0 X, Y, Z

) 2< X < 20 X, Y 1-

:

.

.

, .

: GOTO N

N - , .

:

1. X=3 2. GOTO W

GOTO 7 . . .

Y=2*X W PRINT " "

7 Z=5*X

: .

 

 


: .

I.   ( "" "").

1) ( )

""


IF THEN 1 ELSE 2


""

: ( - , ). , 1, , 2.

: IF A=1 THEN PRINT "" ELSE PRINT ""

PRINT ""

:

n =1 "", PRINT "" PRINT "";

n =1 "", PRINT"" PRINT "".

2) :

IF THEN :

⠠ CLS: INPUT a

"" IF a=1 THEN

ELSE PRINT " "

PRINT a

"" ELSE

END IF PRINT " "

PRINT a

END IF

II. :

IF THEN

.

1. , .

CLS: INPUT " ";X, Y

IF X > Y THEN

PRINT " X="; X

ELSE

PRINT " Y=";Y

END IF

END

2. .

X2 +4X-7 , X<=-2 CLS: INPUT " X";X

Y=< IF X<=-2 THEN

X2-3X+12 , X>2 Y=X^2+4*X-7

ELSE

Y=X^2-3*X+12

END IF

PRINT " =";;" =";

END

3. =32 -5+12 (-3,3) 1.

CLS: PRINT "Y", "X"

X=-3

4 Y=3*X^2-5*X+12

PRINT Y,X

X=X+1

IF X<3 THEN GOTO 4

END

4. 10 20

S =10+11+12+...+20

CLS: S=0: X=10

5 S=S+X

X=X+1

IF X<=20 THEN GOTO 5

PRINT " = ";S

END

5. 15 30

= 15*17*19*...*29

CLS:P=1:X=15

7 P=P*X

X=X+2

IF X<30 THEN GOTO 7

PRINT " = ";P

END

.

QBASIC :

n () ( );

n , ( ) .

(FOR... NEXT) ...

, .

:

FOR K=K1 TO K2 STEP K3 -

- ࠠ -

NEXT K -

FOR - ( ""); - ( ), ; 1, 2, 3 - , , ; , S - - "", ""; - ; NEXT - ( "").

:


K < K2, K3 > 0

< > = <

K > K2 , K3 < 0

, FOR NEXT 1 2 3 (), FOR NEXT, .

:

1. 1, 2, 3 FOR NEXT .

2. , FOR, .

1. 1 10.

CLS

FOR J=1 TO 10 STEP 1

PRINT J

NEXT J

END

2. 1 10

CLS: S=0

FOR I=1 TO 10 STEP 1

S=S+I

NEXT I

PRINT " "; S

END

3. 蠠 y=2X2-3X+5 (-3, 3) 1,5

CLS : PRINT "Y"; "X"

FOR X=-3 TO 3 STEP 1.5

Y=2*X^2-3*X+5

PRINT Y,X

NEXT X

END

4. S= 2+4+ ...+2 N , N CLS : S=0

INPUT N; N

FOR I = 1 TO N

S=S + 2 *N

NEXT I

PRINT = ; S

END

5 IBM 10 ,

CLS

FOR K =5 TO 15

LOCATE K, K

PRINT IBM

NEXT K

END

WHILE... WEND (... )

WHILE... WEND (... ) , , WHILE - "".

WHILE

--

WEND

:


Ҡ



, WEND.

, - "", .

WHILE... WEND - WHILE... WEND.

: "", .. .

.

CLS : I=1

WHILE I < 5

PRINT "I=" ; I;

I=I+1

WEND

: I=1 I=2 I=3 I=4

" " " "

1. (+)/2 (+/2) .

2. Z

)Y= (X-15)/(x-6) ; ) Y= 2X-5/(7Z-4X);

X2+5X-14, X<-2

) Y= <

3X2-7X , X>=-2

) 5X2+4X-21 , X < -7

Y=<

2X2-3X , X>=-7

) X+Z , X<10 Z>5

Y= X*Z

3. - , , , , .

4. , .

5. , .

6.

) Y= 5*X2 -4X+11 (-5,5) 1,5;

) X2-2*X+3, X<0

Y= < (-7, 7) 1;

X-18+12, X>=0

) SIN(X), X<=0

Y= < SIN(X)+COS(X), 0<X<3

COS(X), X>=3;

(-6, 6) 0,5.

7. 1 10.

8. 1 20.

9. 15 20.

10. :

) 10 20;

) 20 20;

) 20 40;

) 20 40;

) 1 20;

) 1 20.

11. 10 "PENTIUM" .

12. , . , .

13. , :

) "*" ;

) "*" ;

) "*" .

14. , N :

) 1 1 1 ) 1 1 1

15 + 25 + ... + N5 ; (3)2 + (5)2 + ... + (2N+1)2 ;

15. , :

) 1 1 1 ;

(1+12)*(1+22)...(1+N2)

) A*(A-N)*(A-2N)...(A-N*N); ) 2*4*6*...*2*N .

16. :

) ; ) ; ) .

17.

) 1 20 ; ) 20 100.

18. .

, , . ( , ) , .

- , . . , .

, $, .

: , . ( ), . - , .

,

) :

A$=" "

T$="" -

) :

PRINT A$, T$

) :

T$=A$+B$

P$=": "+P$

C$=""+" "+""

) :

INPUT A$, B$

- .

:

VAL(A$) - ;

CHR$(L) - ;

ASC(S$) -

SRT$(K) - , ;

LEN(F$) - ;

LEFT$( F$, N) - ;

RIGHT$ (F$, N) - ;

MID$(F$, N1, N2) -

.

1. , "F".

CLS

INPUT " - ";S$

K=0

FOR I=1 TO LEN(S$)

IF MID$(S$, I, 1)="F" THEN K=K+1

NEXT I

PRINT " F ";K;" () "

END

2 . , .

CLS

INPUT " - ";S$

FOR I=LEN(S$) TO 1 STEP -1

PRINT MID$(S$, I, 1);

NEXT I

END

3. , "". , .

CLS: INPUT " - ";S$

K=0

FOR I=1 TO LEN(S$)

IF MID$(S$, I, 1)="" THEN 80

NEXT I

PRINT " "

GOTO 90

80 PRINT " "; I ; " - "

90 END

1.  F.

2.  , .

3.  .

4.  .

5.  , (, , ..)

6.  1 n , (5 25, 6 36, 25 625 ..)

7.  , . , .

8.  , W. , .

9.  b.

10. , . .

11. , . .

12. , (*) , . . .

13. , (*) - ( , ). .

14. , , , + ² - ² ( , ). .

15. ² ² 󠠠 ² b ². , , .

16. (, ).

17. 5 ( , ), ² f ². , .

18. - .  ² ², ² ², ² D ², . .

19. .

20. , , .

21. , .

22. , ² abcd ².

23. , ² abc ² ² abcd ².

24., ² ², , , .

25. n, s1,...sn. s1,...sn, , :

) ;

) (.. );

) ;

) (.. ).

26. n, s1,...sn. , s1,...sn sj,sj+1, sj - , sj+1 - .

27. n, s1,...sn. j, sj sj+1 . s1,...sn , 0.

, . , - :

1, 2 , .... , n

(1) (2) ... (N)

- , .

DIM ()

DIM , . .

DIM A(7) (⠠

)

DIM

ࠠ ,

.

(0) (1) (2) (3) (4) (5) (6) (7)

: , GOTO.

:

1) 젠 (5)

2) 젠 ,

3) 젠 3,2

:

1) DIM A (5)

A(0)=4: A(I)=-2.5: (3)=10: A(4)=0: A(5)=6: A(2)=3

,

2)

DIM (9)

FOR I=0 TO 9

INPUT A(I)

NEXT I

3) DIM B (6)

DATA 0, -2, 1, 5, 8, 5, 6. 26

FOR N=0 TO 6

READ B (N)

NEXT N

:

1) DIM A(3)

PRINT A(0), A(I), A(2), A(3)

,

2) DIM A(10)

FOR I=0 TO 9

PRINT A(I)

NEXT I

1. 10 .

DIM A (9)

S=0

FOR N=0 TO 9

S=S+A(N)

NEXT N

PRINT ²=²;S

2.

DIM L (9)

MIN=L(0): K=0

FOR I=1 TO 9

IF MIN>L(I) THEN MIN=L(I):K=I

NEXT I

PRINT ²²; MIN

3. 2 (9), (9). ,

DIM A(9), B(9), C(9)

FOR I=0 TO 9

C(I)=A(I)+B(I): PRINT C(I)

NEXT I

1 ( ) 2 ( DIM A(9) ).

CLS DIM A(9)

FOR i = 0 TO 9 PRINT 10

INPUT A (i) FOR i=0 TO 9

NEXT i INPUT A(i)

FOR i = 0 TO 9 NEXT i

FOR y = 9 TO i STEP - 1 FOR i=0 TO 9

IF A (y) >A(y-1) THEN GOTO 20 P=A(i) : K=i

m = A (y) FOR y=i+1 TO 9

A (y) = A (y-1) : A (y-1) = m IF A(y)>P THEN GOTO 50

20 NEXT y P=A(y):K=y

NEXT i 50 NEXT y

FOR i=0 TO 9 A(K)=A(i):A(i)=P

PRINT (i) NEXT i

NEXT i PRINT

FOR i=0 TO 9

PRINT A(i)

NEXT i

END

3 ( )

DIM A (10), (9)

PRINT 10

FOR i=0 TO 9

INPUT B (i)

NEXT i

FOR i=1 TO 10

A(i)=B(i-1)

NEXT i

FOR i=1 TO 10

P=A(I):Y=I-1

40IF P<A(Y) AND Y>0 THEN A(Y+1)=A(Y):Y=Y-1:GOTO 40

A(Y+1)=P

NEXT i

PRINT

FOR i=1 TO 10

PRINT A (i)

NEXT i

END

.

1.  (k), (m) .

2.  k X(k). .

(X1-P)2+(X2-P)2+...+(Xk-P)2, =1+2+...+k)/k.

3. m ՠ ( m ). .

(2+21)*(2+22)*...*(2+2m).

4. (k), ,

=(1+2+...+k)/k

5. , m (m). , , , , .

6. (m) , , , , .

7. (m).

8. (m) , .

9. k (k). .

10. m (m). .

11. m, , 2m 1, 1, 2,2,...,m,Ym 1, 2,...,m. .

12. (m), (k).

13. (m). .

14. (m), .

15. (m) .

16. (m) .

17. (m).

18. (m). .

19. (m) .

20. (m) .

21. (m).

22. (m) .

23. (m) .

24. (m) (m)

(1,1,2,2,..., (m), (m) 2m .

25. (m) .

26. (m), (k)

((1,2,3,..., m, 1,2,3,...,k) m+k .

27. (m).

28. (m).

29. (m) , .. m,...,X2,1.

30. (m) .

31. (m) , ?

32. (m) .

33. (m) ?

34. (m) .

35. (k) (k) :

2-(1-1)2 +(2-2)2+...+(-)2.

36. (k). .

37. (k) .

38. (k), [A,B], .

39. k (k), Y(k). I .

40. (k).

41. (2*N) N . : 1,1,2,2,3,3 .. , , .

42. N x M N 1,2,3 ,..., . , , , . , .

43. :

- ;

- ;

- ;

- ;

....

- .

44. . , 7%.

45. . , . , , .

46. . .

47. , 23 25 , . , , 180 .

48. 20 3,4,5. , 5,4 3 , .

49. 6 . , . - .

50. 15 : , , , . , , .

51. , . 15 , . .

52. 18 . , . , 38 .

53. , , 2 , 1 . 30 . . 30 , . 30 .

54. 1000 . S% . :

) R ?

) 15 ?

- . .

:

1. SCREEN N- , N - (0 - , 1 13 - )

2. PSET (X,Y) - , (0<= X<=Xʠ 0<=Y<= Y, - )

3. LINE (X1, Y1) - (X2, Y2) - ,

(X1, Y1), (X2, Y2)- ,

LINE (X1, Y1) - (X2, Y2),, B-

X2,Y2

, B

BF,

X1, Y1

4. CIRCLE (X, Y),R -

CIRCLE (X, Y),R,,A,B - A B , ( . ).



5. PAINT (X, Y) -

,

, :

- ,

0<=X<=639,

0<=Y<=190.

1. , .

CLS

SCREEN 2

PSET (100,100)

PSET (200,100)

PSET (150,200)

END

2. .

CLS

SCREEN 12

FOR X=0 TO 639

Y=-425/600*X+460

PSET (X, Y)

NEXT X

END

3. n

INPUT N

SCREEN 2

CLS

FOR X=1 TO N

R=1+3.14*(X -1)

CIRCLE (315, 100) ,R,

NEXT X

END

4. 10 , , RND.

CLS

SCREEN 2

FOR I=1 TO 10

CIRCLE (RND(1) * 639, RND(1)*190), RND(1)*100,0,0.14

NEXT I

END

5. ,

SCREEN 2

CLS

LINE (60, 30) - (180, 150),,B

CIRCLE (120, 90), 60

PAINT (61, 31)

PAINT (179, 149)

END

.

, , , . , ( ) .

, =22+1. , . =2+1 .

( ). , (0,0) , (,) (-0,-0). , .

, , : 319 , 640 480. 640 , 320, .. 0 319 . , : =1, =1, 639 [-1,1] 2/639 1/319.

1. =2+4

screen 2

line (320,0)-(320,200)

line (0,100)-(640,100)

for x =-20 to 20

y= (2*x+4)*(-1)

pset (x+320,y+100)

next x

2. =3.

screen 12

line (0,240)-(640,240),13

line (320,0)-(320,480),13

for x=-20 to 20 step 0.01

y=x^3

pset (320+4*x,240+y),3

next

3. , :

{ =2

{ =+6

:

screen 12

line (320,500)-(320,10),9

line (0,100)-(620,100),9

for x=-10 to 10 step 0.01

y=-x^2

pset (320+4*x,160+y),10

next x

for x=-100 to 100 step .01

y=-6-x

pset (320+x,160+y),12

next x

line (320,10)-(300,50),9

line (320,10)-(340,50),9

.. .

" "

1. = 1/2+3

2. =2+4

3. , :

{=2+5

{=|x|

4. . :

{=+2

{=|x|

5. , :

{=2-7/

{=-+6

6. , :

{=3

{=|x|

7. =os().

8. = 2+sin (x).

9. =2+SIN(X/2).

10. = 1/2*COS (X)

11. Y=TAN(X)

12. =0,5*COS(X)-1


2012 , .