tag:blogger.com,1999:blog-44681226918742423852024-02-19T20:44:37.477-08:00martirosАлгоритмы и структуры данных (c++, c#, php)4http://www.blogger.com/profile/14861380304675722754noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-4468122691874242385.post-5913084546555251572021-10-09T10:30:00.001-07:002021-10-09T10:30:15.328-07:00Сети: Cisco paket tracer и задачи<p>Cisco Packet Tracer - это программное обеспечение для моделирования сетей, предназначенное для моделирования сетевых устройств Cisco. Вы можете использовать Cisco Packet Tracer для проектирования простых и довольно сложных сетевых топологий. Вы также можете настроить виртуальные машины, маршрутизаторы, коммутаторы и другие устройства в Packet Tracer для проверки топологии сети.</p><p>как скачать и для чего подробнее - <a href="https://wiki.merionet.ru/seti/50/ustanovka-i-zapusk-cisco-packet-tracer/">читать тут</a>, <a href="https://www.netacad.com/ru/courses/packet-tracer">ориг сайт</a></p><p>задачки 2014 года</p><p><a href="https://drive.google.com/drive/folders/1Eev0nYAKR1NS4A7hXcyf5aQKLOG30PSN?usp=sharing">фулл</a></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrY72tq9-4gZ7Qvhpmh2oKSJfJ2MyrP5vkxyvTgHIxrwkQuRAc6gE7uRbIGsNPtzRAp1Qvhk94tozhmWeWyGlJpMyBhhPy6CqWcSS80g5bgmBtUZRXGPS_Nyzxy6G9QYXbjQEzHEVOsLXH/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="603" data-original-width="616" height="627" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrY72tq9-4gZ7Qvhpmh2oKSJfJ2MyrP5vkxyvTgHIxrwkQuRAc6gE7uRbIGsNPtzRAp1Qvhk94tozhmWeWyGlJpMyBhhPy6CqWcSS80g5bgmBtUZRXGPS_Nyzxy6G9QYXbjQEzHEVOsLXH/w640-h627/image.png" width="640" /></a></div><br /><br /><p></p>4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-70205773792168373452019-10-18T00:31:00.001-07:002019-10-18T00:34:05.078-07:00OpenCV : colorpicker from video pixel<div dir="ltr" style="text-align: left;" trbidi="on">
<pre style="background-color: white; font-family: "Courier New";">● OpenCV приложение1 (2016г)
– Входные данные: поток web-камеры
– Вывод: Графическое окно с текущем кадром потока. На на кадре
текстом выведен код цвета под курсором.</pre>
<pre style="background-color: white; font-family: "Courier New";"><span style="color: grey; font-style: italic;">
</span></pre>
<pre style="background-color: white; font-family: "Courier New";"><span style="color: grey; font-style: italic;">#laba1</span><span style="color: grey; font-style: italic;">
</span><span style="color: navy; font-weight: bold;">import </span>numpy <span style="color: navy; font-weight: bold;">as </span>np
<span style="color: navy; font-weight: bold;">import </span>cv2
capture=cv2.VideoCapture(<span style="color: blue;">0</span>)
<span style="color: navy; font-weight: bold;">global </span>r,b,y
<span style="color: navy; font-weight: bold;">global </span>im,location
strings = <span style="color: green; font-weight: bold;">"q"</span>xi=<span style="color: blue;">100</span>yi=<span style="color: blue;">100</span><span style="color: blue;">
</span><span style="color: navy; font-weight: bold;">def </span>showcolor(<span style="color: grey;">event</span>,x,<span style="background-color: #e4e4ff;">y</span>,<span style="color: grey;">flags</span>,<span style="color: grey;">param</span>):
<span style="color: navy; font-weight: bold;">global </span>xi, yi
xi=x
yi=<span style="background-color: #e4e4ff;">y</span>
<span style="color: navy; font-weight: bold;">while </span><span style="color: navy;">True</span>:
b,frame=capture.read()
im=frame
msg = strings
fontface = cv2.FONT_HERSHEY_SIMPLEX
fontscale = <span style="color: blue;">1.0</span><span style="color: blue;"> </span>location = (xi, yi)
b = im[yi, xi][<span style="color: blue;">0</span>]
g = im[yi, xi][<span style="color: blue;">1</span>]
r = im[yi, xi][<span style="color: blue;">2</span>]
strings = r.astype(<span style="color: navy;">str</span>) + <span style="color: green; font-weight: bold;">" " </span>+ g.astype(<span style="color: navy;">str</span>) + <span style="color: green; font-weight: bold;">" " </span>+ b.astype(<span style="color: navy;">str</span>)
clr = np.array([r.astype(<span style="color: navy;">int</span>), g.astype(<span style="color: navy;">int</span>), b.astype(<span style="color: navy;">int</span>)])
color = (r.astype(<span style="color: navy;">int</span>), <span style="color: blue;">190</span>, <span style="color: blue;">0</span>)
cv2.putText(frame, msg, location, fontface, fontscale, <span style="color: #660099;">color</span>=(clr[<span style="color: blue;">0</span>], clr[<span style="color: blue;">1</span>], clr[<span style="color: blue;">2</span>]))
cv2.imshow(<span style="color: green; font-weight: bold;">"image"</span>, frame)
cv2.setMouseCallback(<span style="color: green; font-weight: bold;">'image'</span>, showcolor)
<span style="color: navy; font-weight: bold;">if </span>cv2.waitKey(<span style="color: blue;">1</span>) & <span style="color: blue;">0xFF </span>== <span style="color: navy;">ord</span>(<span style="color: green; font-weight: bold;">'q'</span>):
<span style="color: navy; font-weight: bold;">break</span><span style="color: navy; font-weight: bold;">
</span>capture.release()
cv2.destroyAllWindows()
</pre>
</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-52615775853881626272016-06-01T15:13:00.002-07:002016-06-02T02:29:38.517-07:00Создание инфоблока "экзамены" . 1С Битрикс API<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><i><span style="background-color: white; color: #222222;">- Инфоблок "Расписание экзаменов" </span><br style="background-color: white; color: #222222;" /><span style="background-color: white; color: #222222;">- Свойства для элементов этого инфоблока: </span><br style="background-color: white; color: #222222;" /><span style="background-color: white; color: #222222;">- "Аудитория" тип целое число </span><br style="background-color: white; color: #222222;" /><span style="background-color: white; color: #222222;">- "Преподаватель" тип строка </span><br style="background-color: white; color: #222222;" /><span style="background-color: white; color: #222222;">- и 5 элеметов этого инфоблока с заполнеными полями: </span><br style="background-color: white; color: #222222;" /><span style="background-color: white; color: #222222;">- Название (стандартное поле инфоблока) </span><br style="background-color: white; color: #222222;" /><span style="background-color: white; color: #222222;">- Аудитория</span><br style="background-color: white; color: #222222;" /><span style="background-color: white; color: #222222;">- Преподаватель </span></i><i><span style="background-color: white; color: #222222;">- Дата начала (стандартное поле инфоблока)</span><span style="background-color: white; color: #222222;"> </span></i></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">__________________________________________</span><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><?php</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">CModule::IncludeModule("iblock");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$ib = new CIBlock;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$IBLOCK_TYPE = "newb"; //тип инфоблока</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$SITE_ID = "s1"; //сайт</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">// Настройка доступа</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arAccess = array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"2" => "R", // Все пользователи</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">if ($contentGroupId) $arAccess[$contentGroupId] = "X"; // Полный доступ</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">if ($editorGroupId) $arAccess[$editorGroupId] = "W"; // Запись</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">if ($ownerGroupId) $arAccess[$ownerGroupId] = "X"; // Полный доступ</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arFields = Array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"ACTIVE" => "Y",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"NAME" => "Расписание экзаменов",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"CODE" => "tm",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"IBLOCK_TYPE_ID" => $IBLOCK_TYPE,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"SITE_ID" => $SITE_ID,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"SORT" => "5",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"GROUP_ID" => $arAccess, // Права доступа</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"FIELDS" => array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">// Символьный код разделов</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"SECTION_CODE" => array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"IS_REQUIRED" => "Y",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"DEFAULT_VALUE" => array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"UNIQUE" => "Y",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"TRANSLITERATION" => "Y",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"TRANS_LEN" => "30",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"TRANS_CASE" => "L",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"TRANS_SPACE" => "-",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"TRANS_OTHER" => "-",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"TRANS_EAT" => "Y",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"USE_GOOGLE" => "N",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"DETAIL_TEXT_TYPE" => array( // Тип детального описания</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"DEFAULT_VALUE" => "html",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"SECTION_DESCRIPTION_TYPE" => array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"DEFAULT_VALUE" => "html",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"IBLOCK_SECTION" => array( // Привязка к разделам обязательноа</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"IS_REQUIRED" => "N",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"LOG_SECTION_ADD" => array("IS_REQUIRED" => "Y"), // Журналирование</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"LOG_SECTION_EDIT" => array("IS_REQUIRED" => "Y"),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"LOG_SECTION_DELETE" => array("IS_REQUIRED" => "Y"),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"LOG_ELEMENT_ADD" => array("IS_REQUIRED" => "Y"),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"LOG_ELEMENT_EDIT" => array("IS_REQUIRED" => "Y"),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"LOG_ELEMENT_DELETE" => array("IS_REQUIRED" => "Y"),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">),</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">// Шаблоны страниц</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"LIST_PAGE_URL" => "#SITE_DIR#/tm/",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"SECTION_PAGE_URL" => "#SITE_DIR#/tm/#SECTION_CODE#/",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"DETAIL_PAGE_URL" => "#SITE_DIR#/tm/#SECTION_CODE#/#ELEMENT_CODE#/",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"INDEX_SECTION" => "Y", // Индексировать разделы для модуля поиска</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"INDEX_ELEMENT" => "Y", // Индексировать элементы для модуля поиска</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"VERSION" => 1, // Хранение элементов в общей таблице</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"SECTION_PROPERTY" => "Y", // Разделы каталога имеют свои свойства (нужно для модуля интернет-магазина)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$ID = $ib->Add($arFields);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">if ($ID > 0)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">{</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "инфоблок успешно создан";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">else</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">{</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "ошибка создания инфоблока";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">return false;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$propid1=0;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$propid2=0;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">// Определяем, есть ли у инфоблока свойства</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$dbProperties = CIBlockProperty::GetList(array(), array("IBLOCK_ID"=>$ID));</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">if ($dbProperties->SelectedRowsCount() <= 0)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">{</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$ibp = new CIBlockProperty;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arFields = Array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"NAME" => "Аудитория",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"ACTIVE" => "Y",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"SORT" => -777, // Сортировка</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"CODE" => "Number",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"PROPERTY_TYPE" => "N", //</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"IBLOCK_ID" => $ID</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$propId = $ibp->Add($arFields);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">if ($propId > 0)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">{</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arFields["ID"] = $propId;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$propid1=$propId;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arCommonProps[$arFields["CODE"]] = $arFields;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "&mdash; Добавлено свойство ".$arFields["NAME"]."<br />";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">else</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "&mdash; Ошибка добавления свойства ".$arFields["NAME"]."<br />";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">/* сео-свойства */</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arFields = Array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"NAME" => "Преподаватель",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"ACTIVE" => "Y",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"SORT" => -777,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"CODE" => "Name",</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"PROPERTY_TYPE" => "S", // Строка</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"IBLOCK_ID" => $ID,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$propId = $ibp->Add($arFields);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">if ($propId > 0)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">{</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arFields["ID"] = $propId;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$propid2=$propId;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arCommonProps[$arFields["CODE"]] = $arFields;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "&mdash; Добавлено свойство ".$arFields["NAME"]."<br />";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">else</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "Ошибка добавления свойства ".$arFields["NAME"]."<br />";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">else</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "Для данного инфоблока уже существуют свойства<br />";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$el = new CIBlockElement;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">for($i=0;$i<5;$i++){</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$PROP = array();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$PROP[$propid1] = "Преподаватель".$i; //</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$PROP[$propid2] = "Аудитория".$i;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$date = "31.05.2016 ".$i.":32:00";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$stmp = MakeTimeStamp($date, "DD.MM.YYYY HH:MI:SS");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$arLoadProductArray = Array(</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"MODIFIED_BY" => $USER->GetID(), // элемент изменен текущим пользователем</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"IBLOCK_SECTION_ID" => false, // элемент лежит в корне раздела</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"IBLOCK_ID" => $ID,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"PROPERTY_VALUES"=> $PROP,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"NAME" => "Предмет #".$i,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"ACTIVE" => "Y", // активен</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"PREVIEW_TEXT" => "текст для предмета #".$i,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"DETAIL_TEXT" => "текст для детального просмотра элементa #".$i,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"ACTIVE_FROM" => $date,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"START_DATE"=> $date,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">"DATE_ACTIVE_FROM"=>$date</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">if($PRODUCT_ID = $el->Add($arLoadProductArray))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "New ID: ".$PRODUCT_ID;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">else</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">echo "Error: ".$el->LAST_ERROR;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">?></span></div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-78460507629287314292016-06-01T14:34:00.002-07:002016-06-02T02:30:35.959-07:00Обратная польская запись<div dir="ltr" style="text-align: left;" trbidi="on">
<h1 class="firstHeading" id="firstHeading" lang="en" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; font-family: "Linux Libertine", Georgia, Times, serif; font-size: 1.8em; font-weight: normal; line-height: 1.3; margin: 0px 0px 0.25em; overflow: visible; padding: 0px;">
<span style="background-color: white;">
Reverse Polish notation</span></h1>
<span style="background-color: white;"><span style="color: #6a6a6a; font-family: "arial" , sans-serif; font-size: x-small; font-weight: bold; line-height: 18.2px;">Обратная польская</span><span style="color: #545454; font-family: "arial" , sans-serif; font-size: x-small; line-height: 18.2px;"> нотация (ОПН) </span></span><br />
<span style="background-color: white; color: #545454; font-family: "arial" , sans-serif; font-size: x-small; line-height: 18.2px;">описание на <a href="https://ru.wikipedia.org/wiki/%D0%9E%D0%B1%D1%80%D0%B0%D1%82%D0%BD%D0%B0%D1%8F_%D0%BF%D0%BE%D0%BB%D1%8C%D1%81%D0%BA%D0%B0%D1%8F_%D0%B7%D0%B0%D0%BF%D0%B8%D1%81%D1%8C">вики</a></span><br />
<span style="background-color: white;"><br /></span>
<span style="background-color: white;">код PHP</span><br />
<span style="background-color: #cccccc; font-family: "courier new" , "courier" , monospace;"><span style="background-color: white;"><br /></span>
</span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><<b>?php function polish($input){ </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b>$input=str_replace(" ","",$input); </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b>for($i=0;$i<strlen($input);$i++){ </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> if(is_numeric($input[$i])){ </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> $stack[]=$input[$i];</b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> } </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> else { </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> $n2 = array_pop($stack);</b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> $n1 = array_pop($stack); </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> switch($input[$i]) { </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> case '+': $result = $n1 + $n2; break; </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> case '-': $result = $n1 - $n2; break; </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> case '*': $result = $n1 * $n2; break; </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> case '/': $result = $n1 / $n2; break; </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> default: echo "Ощибка ввода!\n"; </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> } </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> array_push($stack,$result); </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> } </b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> }</b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b> return array_pop($stack);</b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b>}</b></span><br />
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b><br /></b></span>
<span style="background-color: white; font-family: "courier new" , "courier" , monospace;"><b>echo polish("5 8 3 + *");?></b></span></div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-14087249260242983732013-09-25T01:41:00.000-07:002016-06-02T02:31:32.185-07:00с++ / Задача Иосифа Флавия<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 class="post-title entry-title" itemprop="name" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 22px; font-weight: normal; margin: 0.75em 0px 0px; position: relative;">
Задача Иосифа (циклический список)</h3>
<div class="post-header" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 11px; line-height: 1.6; margin: 0px 0px 1.5em;">
<div class="post-header-line-1">
</div>
</div>
<div class="post-body entry-content" id="post-body-4299519342211920560" itemprop="description articleBody" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 1.4; position: relative; width: 546px;">
<div dir="ltr" trbidi="on">
Описание задачи:<br />
<a href="http://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B4%D0%B0%D1%87%D0%B0_%D0%98%D0%BE%D1%81%D0%B8%D1%84%D0%B0_%D0%A4%D0%BB%D0%B0%D0%B2%D0%B8%D1%8F" style="color: #888888; text-decoration: none;">http://ru.wikipedia.org/wiki/Задача Иосифа</a><br />
<br />
<br />
Решение (Перебором от<b> </b><a href="http://cppalgorithms.blogspot.ru/" style="line-height: 1.4;"><b>http://cppalgorithms.blogspot.r</b>u</a> ) <span style="line-height: 1.4;">:</span></div>
<div dir="ltr" trbidi="on">
<br />
<br />
#include <iostream><br />
using namespace std;<br />
<br />
class Node //Узел связного списка<br />
{<br />
public:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int m_item;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Node *m_next;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Node(int item, Node *next){m_item = item, m_next = next;}<br />
};<br />
<br />
int main()<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cout << "Enter number of people: ";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int numberOfPeople = 0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cin >> numberOfPeople;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cout << "Enter interval: ";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int interval;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cin >> interval;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Node *first =new Node(1, 0); //Создаем первый узел. m_item содержит номер<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>first->m_next = first;<span class="Apple-tab-span" style="white-space: pre;"> </span> //и зацикливаем его на себя<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Node *tmp = first;<span class="Apple-tab-span" style="white-space: pre;"> </span> //Указатель с которым будем работать в дальнейшем<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = 2; i <= numberOfPeople; ++i) //Создаем циклический список<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>tmp->m_next = new Node(i, first);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>tmp = tmp->m_next;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while (tmp != tmp->m_next) //Удаляем элемент через интервал<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = 1; i < interval; ++i)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>tmp = tmp->m_next;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Node *deleteNode = tmp->m_next;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>tmp->m_next = tmp->m_next->m_next;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>delete deleteNode;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cout << tmp->m_item << endl; //Выводим оставшийся<br />
}</div>
<div dir="ltr" trbidi="on">
<br /></div>
<div dir="ltr" trbidi="on">
/////////////////////////////////////////////////</div>
<div dir="ltr" trbidi="on">
<div style="color: #222222; font-family: Arial; font-size: 16px; line-height: normal; margin-bottom: 10px; margin-top: 10px; padding: 0px;">
Простая <b>рекурсивная реализация</b> (в 1-индексации):</div>
<pre class="notranslate cpp" style="background-color: #f0f0f0; border: 1px dotted rgb(160, 160, 160); color: #0000bb; font-family: 'Courier New', Courier, monospace; font-size: 16px; line-height: normal; padding: 5px 10px;"><span class="kw4" style="color: #f63333;">int</span> joseph <span class="br0" style="color: #66cc66;">(</span><span class="kw4" style="color: #f63333;">int</span> n, <span class="kw4" style="color: #f63333;">int</span> k<span class="br0" style="color: #66cc66;">)</span> <span class="br0" style="color: #66cc66;">{</span>
<span class="kw1" style="color: #a1a100;">return</span> n<span class="sy1">></span><span class="nu0" style="color: #ff33ff;">1</span> <span class="sy4">?</span> <span class="br0" style="color: #66cc66;">(</span>joseph <span class="br0" style="color: #66cc66;">(</span>n<span class="sy2">-</span><span class="nu0" style="color: #ff33ff;">1</span>, k<span class="br0" style="color: #66cc66;">)</span> <span class="sy2">+</span> k <span class="sy2">-</span> <span class="nu0" style="color: #ff33ff;">1</span><span class="br0" style="color: #66cc66;">)</span> <span class="sy2">%</span> n <span class="sy2">+</span> <span class="nu0" style="color: #ff33ff;">1</span> <span class="sy4">:</span> <span class="nu0" style="color: #ff33ff;">1</span><span class="sy4">;</span>
<span class="br0" style="color: #66cc66;">}</span></pre>
<div style="color: #222222; font-family: Arial; font-size: 16px; line-height: normal; margin-bottom: 10px; margin-top: 10px; padding: 0px;">
<b>Нерекурсивная форма</b>:</div>
<pre class="notranslate cpp" style="background-color: #f0f0f0; border: 1px dotted rgb(160, 160, 160); color: #0000bb; font-family: 'Courier New', Courier, monospace; font-size: 16px; line-height: normal; padding: 5px 10px;"><span class="kw4" style="color: #f63333;">int</span> joseph <span class="br0" style="color: #66cc66;">(</span><span class="kw4" style="color: #f63333;">int</span> n, <span class="kw4" style="color: #f63333;">int</span> k<span class="br0" style="color: #66cc66;">)</span> <span class="br0" style="color: #66cc66;">{</span>
<span class="kw4" style="color: #f63333;">int</span> res <span class="sy1">=</span> <span class="nu0" style="color: #ff33ff;">0</span><span class="sy4">;</span>
<span class="kw1" style="color: #a1a100;">for</span> <span class="br0" style="color: #66cc66;">(</span><span class="kw4" style="color: #f63333;">int</span> i<span class="sy1">=</span><span class="nu0" style="color: #ff33ff;">1</span><span class="sy4">;</span> i<span class="sy1"><=</span>n<span class="sy4">;</span> <span class="sy2">++</span>i<span class="br0" style="color: #66cc66;">)</span>
res <span class="sy1">=</span> <span class="br0" style="color: #66cc66;">(</span>res <span class="sy2">+</span> k<span class="br0" style="color: #66cc66;">)</span> <span class="sy2">%</span> i<span class="sy4">;</span>
<span class="kw1" style="color: #a1a100;">return</span> res <span class="sy2">+</span> <span class="nu0" style="color: #ff33ff;">1</span><span class="sy4">;</span>
<span class="br0" style="color: #66cc66;">}</span></pre>
</div>
</div>
</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com1tag:blogger.com,1999:blog-4468122691874242385.post-19899100961714018762013-09-25T01:37:00.002-07:002013-09-25T01:37:54.703-07:00с++ / Остатки <div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<b>Остатки</b><span class="3"><span style="font-size: 13.0pt;">.</span></span> Задумано целое число Х. Известны числа <span lang="EN-US">k</span>, <span lang="EN-US">m</span>, <span lang="EN-US">n</span> – остатки от деления этого числа на 3, 5, 7 соответственно.
Найдите число Х.<b><i><o:p></o:p></i></b></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
#include <iostream></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
using namespace std;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
int main()</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
{</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>int k,m,n,p;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>cin>>k>>m>>n;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<"interval";</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>cin>>p;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
for(int x=0; x<p; x++) </div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
{</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
if ((x%3)==k && (x%5)==m && (x%7)==n)</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
{</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
cout<<x<<endl;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
}</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
}</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
return 0;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
}</div>
</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-1514469144524358872013-09-25T01:36:00.004-07:002013-09-25T01:36:56.260-07:00c++ / диагональ прямоугольника<div dir="ltr" style="text-align: left;" trbidi="on">
//Прямоугольник, стороны которого выражены натуральными числами M и N ,<br />
//разделен на квадраты размером 1 x 1. Найти число квадратов, пересекаемых диагональю<br />
//прямоугольника (пересекает только тогда, когда делит его на две произвольные части).<br />
<br />
#include <iostream><br />
using namespace std;<br />
int euclid(int A, int B)<br />
{<br />
// return B ? euclid(B, A % B) : A;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (B)<br />
return euclid(B, A % B);<br />
else<br />
return A;<br />
}<br />
<br />
int chislo_kvad(int A, int B )<br />
{<br />
return A + B - euclid(A, B);<br />
}<br />
<br />
int main()<br />
{<br />
std::locale::global(std::locale(""));<br />
std::cout << "стороны прямоугольника:"<br />
<< std::endl<br />
<< '\t'<br />
<< "A = ";<br />
<br />
int A = 0;<br />
std::cin >> A;<br />
std::cout << '\t'<br />
<< "B = ";<br />
int B = 0;<br />
std::cin >> B;<br />
<br />
std::cout<br />
<< chislo_kvad(A, B)<br />
<< " квадратов."<br />
<< std::endl;<br />
}*/</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-76021625147651259102013-09-25T01:35:00.002-07:002013-09-25T01:35:45.650-07:00с++ / последовательность 1 22 333 4444<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
Вычислить <span lang="EN-US">n</span>-ый член последовательности натуральных чисел 1, 2, 2, 3, 3, 3,
4, 4, 4, 4, … по заданному <span lang="EN-US">n</span>.<b><i><o:p></o:p></i></b></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
#include <iostream></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
using namespace std;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
int main()</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
{</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>int a,b,k;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>cin>>a;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(a<1)</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<"FALSE";</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>else</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>k=1;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>b=0;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(b<a)</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>b=b+k;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>k++;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<k-1<<endl;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
return 0;</div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;">
}</div>
</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-15473148911159686092013-09-25T01:34:00.001-07:002013-09-25T01:34:32.358-07:00с++ / текст (от n до m)<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
Дан текстовый файл, содержащий буквенные и цифровые
символы. Требуется скопировать часть файла с позиции <span lang="EN-US">n</span><span lang="EN-US"> </span>до позиции <span lang="EN-US">m</span> в поток и посчитать в этой
части количество цифровых символов.<o:p></o:p></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
#include <fstream></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
#include <iostream></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
using namespace std;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
int main()</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
{ </div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
ifstream ifs("1.txt");</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
if(!ifs) </div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
{</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
cerr << "File error." << endl;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
return 1;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
}</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
int n, m;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
do</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
{</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
(cin >> n >> m).get();</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
} </div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
while (n < 0 || m < 0 || m <= n);</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
ifs.seekg(n);</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
int kol = 0;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
char temp;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
while(ifs.get(temp))</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
{</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
if(isdigit(temp))</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
{</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
kol++;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
cout << temp << ' ';</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
}</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
++n;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
if (n == m) break; </div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
}</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
cout << endl << kol << endl;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
cin.get();</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
return 0;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
}</div>
</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-44298775948058584252013-09-25T01:29:00.004-07:002013-09-25T01:29:53.843-07:00c++ / Колония роботов<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
Колония роботов живет и развивается по следующим
законам: один раз в начале года они объединяются в группы по 3 или 5 роботов.
За один год группа из 3 роботов собирает 5 новых роботов, а группа из 5 роботов
собирает 9 новых роботов. Роботы объединяются так, чтобы собрать за год наибольшее
количество новых роботов. Каждый робот живет три года после сборки. Известно,
что начальное количество роботов равно <span lang="EN-US">k</span> и все они только что собраны. Сколько роботов будет содержать
колония через <span lang="EN-US">n </span>лет?<b><i><o:p></o:p></i></b></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
#include <iostream></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
using namespace std;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
int main()</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
{ </div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
int a;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
int c=0,b=0,d=0;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
int m=0;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
cin>> a;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
int n;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
cin>>n;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
for(int i=1;i<n;i++)</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{ d=a+b+c;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
if(d<3)</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>d=0;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
if(d==4 || d==7)</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>d-=1;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
m=d%5;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
c=b;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
b=a;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
a=d*2-d/5-m%3-m/3;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
}</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
cout<<a+b+c<<endl;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return 0;</div>
<div class="MsoNormal" style="margin-left: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 21.3pt; text-align: justify; text-indent: 0cm;">
}</div>
</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-55723677026392239622013-09-25T01:28:00.002-07:002013-09-25T01:30:11.424-07:00c++ / Лестница<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-ansi-language: RU; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: RU;">.<b><i>Лестница</i>. </b>Поднимаясь по лестнице,
заяц прыгает либо на следующую ступеньку, либо через одну, либо </span><br />
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-ansi-language: RU; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: RU;"><br /></span>
<span style="font-family: Times New Roman, serif;">#include <iostream></span><br />
<span style="font-family: Times New Roman, serif;">using namespace std;</span><br />
<span style="font-family: Times New Roman, serif;">int main()</span><br />
<span style="font-family: Times New Roman, serif;">{</span><br />
<span style="font-family: Times New Roman, serif;">int a=1,b=2,c=4,d=0,num;</span><br />
<span style="font-family: Times New Roman, serif;">cout<<"количество ступенек = ";</span><br />
<span style="font-family: Times New Roman, serif;">cin>>num;</span><br />
<span style="font-family: Times New Roman, serif;">if(num==1)</span><br />
<span style="font-family: Times New Roman, serif;">{</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>d=a;</span><br />
<span style="font-family: Times New Roman, serif;">}</span><br />
<span style="font-family: Times New Roman, serif;">if(num==2)</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>d=b;</span><br />
<span style="font-family: Times New Roman, serif;">}</span><br />
<span style="font-family: Times New Roman, serif;">if(num==3)</span><br />
<span style="font-family: Times New Roman, serif;">{<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>d=c;</span><br />
<span style="font-family: Times New Roman, serif;">}</span><br />
<span style="font-family: Times New Roman, serif;">if(num>3)</span><br />
<span style="font-family: Times New Roman, serif;">{</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for(int i=0;i<(num-3);i++)</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>d=a+b+c;</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>a=b;</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>b=c;</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>c=d;</span><br />
<span style="font-family: Times New Roman, serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: Times New Roman, serif;">}</span><br />
<span style="font-family: Times New Roman, serif;">cout<<"способoFF = "<<d;</span><br />
<span style="font-family: Times New Roman, serif;">return 0;</span><br />
<br />
<span style="font-family: Times New Roman, serif;">}</span></div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-45771612052671455002013-09-25T01:26:00.002-07:002013-09-25T01:26:21.206-07:00c++ / Квадраты<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<b><i>Квадраты.</i></b> От заданного
прямоугольника каждый раз отрезается квадрат максимальной площади (длины сторон
выражаются натуральными числами). Найти количество таких квадратов<o:p></o:p></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<br /></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
#include<iostream></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
using namespace std;</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
int main()</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
{</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span style="text-indent: 0cm;">int x, y;</span></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>cin>>x>>y;</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
int count=0;</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
while(x>0 && y>0)</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
{</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
if(x>y)</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> {</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> x -= y;</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> }</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> else</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> y -= x;</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
count++;</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
}</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
cout<<count;</div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span style="text-indent: 0cm;"> return 0;</span></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="text-indent: 0cm;">}</span></div>
</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0tag:blogger.com,1999:blog-4468122691874242385.post-56052171894210345252013-09-25T01:07:00.000-07:002013-09-25T01:07:18.010-07:00с++ / not(1) = 0, not (0) = 1<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoListParagraph" style="margin-left: 0cm; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: list 0cm left 21.3pt; text-align: justify; text-indent: 0cm;">
<b><span style="font-size: 7pt; font-weight: normal;"> </span></b><!--[endif]--><b><i>Последовательность</i></b> 1, 0, 0, 1, 0, 1,
1, 0, 0, 1, 1, 0, …, состоящая из нулей и единиц строится так: первый ее
элемент равен 1, а остальные получаются из предшествующих с помощью логической
операции отрицания: <span lang="EN-US">not</span>(1)
= 0, <span lang="EN-US">not</span> (0) = 1. Второй
элемент равен отрицанию первого, третий и четвертый – отрицанию первого и
второго соответственно и т.д. По заданному <span lang="EN-US">n</span><span lang="EN-US"> </span>вычислить <span lang="EN-US">n</span>-ый член указанной последовательности.<b><o:p></o:p></b><br />
<br />
<br />
#include <iostream><br />
using namespace std;<br />
int step(int x) //Если 0 или 2^n, то --. результат не может быть 0, 1, 2, 4 и т.д.<br />
{<br />
x--;<br />
while (!(x & (x - 1)))<br />
x--;<br />
return x; <br />
}<br />
<br />
int main(void)<br />
{<br />
int n;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<"CHISLO : ";<br />
cin >> n;<br />
<br />
if (n == 1)<br />
cout << 1;<br />
else if (n == 2)<br />
cout << 0;<br />
else<br />
{<br />
int k = 0;<br />
while(n > 2)<br />
{<br />
n -= step(n);<br />
k++;<br />
}<br />
<br />
if (((n == 1) && (k % 2 != 0)) || ((n == 2) && (k % 2 == 0)))<br />
cout << 1;<br />
else<br />
cout << 0;<br />
}<br />
<br />
return 0; <br />
}</div>
</div>
4http://www.blogger.com/profile/14861380304675722754noreply@blogger.com0