Программирование разветвляющихся алгоритмов

  • Published on
    15-Aug-2015

  • View
    48

  • Download
    1

Embed Size (px)

Transcript

  1. 1.
  2. 2.
  3. 3. elseelse ; . : ifif thenthen elseelse ; : ifif thenthen ; - - !
  4. 4. program n_9; var x, a, b: real; begin writeln (' '); write (' , b>>'); readln (a, b); write (' x>>'); readln (x); if (x>=a) and (x=a) and (xy) then y:=b; if (c>y) then y:=c; writeln ('y=', y) end. Y:=A B>Y Y:=B Y:=C C>Y
  5. 6. thenthen, elseelse . thenthen elseelse , : beginbegin < > endend
  6. 7. - : 1=, 1, 2=, 2 1:=(-b+sqrt(d))/2/a a, b, c d:=b*b-4*a*c d < 0 d:= 0 x:=-b/2/a =, 2:=(-b-sqrt(d))/2/a
  7. 8. begin x1:=(-b+sqrt(d))/2/a; x2:=(-b-sqrt(d))/2/a; writeln (' :'); writeln ('x1=', x1:9:3); writeln ('x2=', x2:9:3) end; begin x1:=(-b+sqrt(d))/2/a; x2:=(-b-sqrt(d))/2/a; writeln (' :'); writeln ('x1=', x1:9:3); writeln ('x2=', x2:9:3) end; begin x:=-b/2/a; writeln (' x=', x:9:3) end; begin x:=-b/2/a; writeln (' x=', x:9:3) end; program n_11; var a, b, c: real; var d: real; var x, x1, x2: real; begin writeln (' '); write (' a, b, c >>'); readln (a, b, c); d:=b*b-4*a*c; if d0 then end.
  8. 9. : ifif thenthen ifif thenthen elseelse elseelse elseelse ifif!
  9. 10. program n_12; var a, b, x: real; begin writeln (' '); write (' a , b>>'); readln (a, b); if a0 then begin x:=-b/a; writeln (' x=', x:9:3) end else if b0 then writeln (' ') else writeln ('x '); end. a, b, x - a, b a0 x:=-b/a b0
  10. 11. : if then else : if then , , : begin < > end.
  11. 12. ? ? ) if x=y then x:=0; y:=0 else write (z) ) if xb then c:=1; if a>b then d:=2; if a1, 2 2- >>3, 4 a b c>> 1 2 1 a b c>> 2 2 2 a b c>> 20 20 30 a b c>> 3 4 5 . , , . , (, , ). . , . k, 1>>-1 5 xa, ya >>1 2 k, 1>>-1 5 xa, ya >>1 10 k, 1>>-1 5 xa, ya >>1 4 , , (, ya): ) y = kx + 1, ; ) x2 + y2 = r2 , . . x >> 5 y >> 6 x = 5 y = 6 x >> 6 y >> 5 x = 5 y = 6 , x y, x y. : If a5 then c:=2 else c:=3 , 3? -5 y = - 1 0 y = 0 5 y = 1 , : -1 x0 y = : , 31 2011 . y , (chislo) 2011 ? chislo:= chislo mod 7 chislo=3 :=' chislo=4 :=' chislo=5 :=' chislo=6 :=' chislo=0 :=' chislo=1 :=' chislo=2 :=' 1 >> 2 2 2 >> 3 3 1 >> 2 3 2 >> 3 3 1 >> 2 7 2 >> 5 4 , 8. , (k, l) (m, n) , . , 100 ( - , 100). .
  12. 13. if then else if then begin < > end

Recommended

View more >