|
|
|
люди помогите пожалуйста!
|
|||
|---|---|---|---|
|
#18+
как из последовательности выделить наибольшую подпоследовательность находящуюся между локальными экстремумами? экстремумы я нашла.....но вот программа находит последовательность только между минимумами....как сделать, чтобы она искала последовательность между всеми экстремумами? <html> <Head> <title>Задача2</title> </Head> <form name = f1> <INPUT TYPE="TEXT" NAME="i1" SIZE=3 value = "15"><br> <Input type = "button" name = "b1" value = "Создать"><br> <Input type = "button" name = "b2" value = "Считать"> </form> <form name = f2> </form> <script language = "VBSCript"> dim i,n,s,a(100),m1,m2,sum,v1,v2,sum1,z,str sub b1_onclick randomize() n=cint(f1.i1.value) for i=0 to n a(i+1)=Int(Rnd(1) * 50 + 1) s=s+"<input type = text size=2 value = "+cstr(a(i+1))+" name=t"+cstr(i)+"> " Next a(0)=a(1)+1 a(n+2)=a(n+1)+1 f2.innerhtml=s s="" end Sub sub b2_onclick For i=0 To n a(i+1) = CInt(document.getElementsByName("t"+CStr(i))(0).value) document.getElementsByName("t"+CStr(i))(0).style.background = "white" Next m1 = 0 m2 = 0 v1 = 0 v2 = 0 sum = 0 for i=1 to n+1 if a(I)>a(i-1) and a(i)>a(i+1) then document.getElementsByName("t"+CStr(i))(0).style.background = "blue" else if a(i)< a(i-1) and a(i)< a(i+1) then document.getElementsByName("t"+CStr(i))(0).style.background = "yellow" If m1 <> 0 Then m2 = i sum1 = 0 For z = m1 + 1 To m2 - 1 sum1 = sum1 + a(z) Next If sum1 > sum Then v1 = m1 v2 = m2 sum = sum1 End If m1 = m2 m2 = 0 Else : m1 = i End If End If End If Next v1 = v1 - 1 v2 = v2 - 1 --> красим последовательность For i=v1+1 To v2-1 document.getElementsByName("t"+CStr(i))(0).style.background = "green" Next --> красим края последовательнсоти document.getElementsByName("t"+CStr(v1))(0).style.background = "red" document.getElementsByName("t"+CStr(v2))(0).style.background = "red" 'msgbox(msgbox(isnumeric(a(2)) and x=1)) end Sub </script> </html> ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 12.12.2010, 20:24 |
|
||
|
люди помогите пожалуйста!
|
|||
|---|---|---|---|
|
#18+
anelochkaкак из последовательности выделить наибольшую подпоследовательность находящуюся между локальными экстремумами? экстремумы я нашла.....но вот программа находит последовательность только между минимумами....как сделать, чтобы она искала последовательность между всеми экстремумами? Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.12.2010, 11:25 |
|
||
|
|

start [/forum/topic.php?fid=16&msg=37010899&tid=1343258]: |
0ms |
get settings: |
8ms |
get forum list: |
19ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
74ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
36ms |
get tp. blocked users: |
1ms |
| others: | 239ms |
| total: | 400ms |

| 0 / 0 |
