<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xmlns:tt="http://teletype.in/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>udarcs</title><generator>teletype.in</generator><description><![CDATA[udarcs]]></description><image><url>https://teletype.in/files/48/d0/48d02251-94a4-4024-867b-6e652f75764a.png</url><title>udarcs</title><link>https://teletype.in/@udarcs</link></image><link>https://teletype.in/@udarcs?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><atom:link rel="self" type="application/rss+xml" href="https://teletype.in/rss/udarcs?offset=0"></atom:link><atom:link rel="next" type="application/rss+xml" href="https://teletype.in/rss/udarcs?offset=10"></atom:link><atom:link rel="search" type="application/opensearchdescription+xml" title="Teletype" href="https://teletype.in/opensearch.xml"></atom:link><pubDate>Thu, 16 Apr 2026 12:42:16 GMT</pubDate><lastBuildDate>Thu, 16 Apr 2026 12:42:16 GMT</lastBuildDate><item><guid isPermaLink="true">https://teletype.in/@udarcs/PaREDM3oFqb</guid><link>https://teletype.in/@udarcs/PaREDM3oFqb?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/PaREDM3oFqb?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>C Piscine Shell 00</title><pubDate>Mon, 14 Jun 2021 12:39:22 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/ac/ff/acff67d4-7ec2-4066-98b4-427c574b5f4f.png"></media:content><description><![CDATA[<img src="https://teletype.in/files/98/0f/980f98c8-9b52-454d-b322-5848f5643d96.png"></img>C Piscine Shell 00 ex00 (Z)]]></description><content:encoded><![CDATA[
  <p>C Piscine Shell 00 <strong>ex00</strong> (Z)</p>
  <p>Задание:</p>
  <p>• Create a file called z that returns &quot;Z&quot;, followed by a new line, whenever the command cat is used on it.</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/98/0f/980f98c8-9b52-454d-b322-5848f5643d96.png" width="561" />
    <figcaption>&quot;Z&quot;</figcaption>
  </figure>
  <p>• Создать файл с именем <code>z</code>, который возвращает <code>Z</code>, за которым следует новая строка всякий раз, когда в нем используется команда <code>cat</code>.</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/98/0f/980f98c8-9b52-454d-b322-5848f5643d96.png" width="561" />
    <figcaption>&quot;Z&quot;</figcaption>
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/d3/8c/d38cff6f-82e8-4e63-b22c-7e95c5e4d11a.png" width="1035" />
  </figure>
  <p>Так же можно создать файл набрав команду текстового редактора Vim</p>
  <p><code>vim z</code></p>
  <p>открыть файл для редактирования <strong>i </strong>записать в него букву<strong> Z</strong></p>
  <p>Закрыть редактирование кнопкой <strong>ESC </strong></p>
  <p>Сохранить и выйти зажать<strong> SHIFT : </strong>набрать в меню<strong> wq</strong></p>
  <p><strong>w</strong> - записать изменения в файл (write)</p>
  <p><strong>q </strong>-выйти (quit)</p>
  <p>Документация читать <a href="https://losst.ru/komanda-ls-linux" target="_blank">(здесь)</a></p>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex01</strong> (Z)</p>
  <p>Задание:</p>
  <p>• Create a file called testShell00 in your submission directory</p>
  <p>• Figure out a way for the output to look like this (except for the “total 1” line):</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/6a/a8/6aa8b1ee-fff0-47ae-9669-d73451a1fa5d.png" width="562" />
    <figcaption>testShell00</figcaption>
  </figure>
  <p>• Once you’ve achieved the previous steps, execute the following command to create the file to be submitted: tar -cf testShell00.tar testShell00.</p>
  <p>• Создать файл с названием <code>testDay00</code> и Задать ему требуемые из скриншота свойства:</p>
  <p>• Не беспокойтесь о том, что у вас вместо XX.</p>
  <p>• Год будет принят вместо времени на метке времени файла.</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/6a/a8/6aa8b1ee-fff0-47ae-9669-d73451a1fa5d.png" width="562" />
    <figcaption>testShell00</figcaption>
  </figure>
  <p>(Необходимо заархивировать и удалить из папки все файлы! Должен остаться только архив <strong>testShell00.tar</strong>)</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/68/6c/686ceb83-6d53-44c5-a2ae-3b52b1b21077.png" width="1192" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/2f/00/2f0079b7-fe7f-4946-b978-29d021b06967.png" width="801" />
  </figure>
  <p><strong>U</strong>ser <strong>G</strong>roup <strong>O</strong>ther к каждой группе мы выдаем права + или -</p>
  <p>Записать права <strong>chmod</strong> o+r <strong>названиефайла.сокращение</strong></p>
  <p>Записать права <strong>chmod</strong> g+r <strong>названиефайла.сокращение</strong></p>
  <p>Записать права <strong>chmod</strong> o+r <strong>названиефайла.сокращение</strong></p>
  <p>Получаем права -r--r--r--</p>
  <h2>Документация.</h2>
  <p>Создание Файлов и управление их временем:</p>
  <p><a href="https://itproffi.ru/sozdanie-fajlov-v-linux-komanda-touch/" target="_blank">https://itproffi.ru/sozdanie-fajlov-v-linux-komanda-touch/</a></p>
  <p>Установка прав чтения/записи/выполнения:</p>
  <p><a href="https://habr.com/ru/post/469667/" target="_blank">https://habr.com/ru/post/469667/</a></p>
  <p>Запись данных в файл:</p>
  <p><a href="https://linux-notes.org/vstavit-tekst-v-fajl-v-unix-linux/" target="_blank">https://linux-notes.org/vstavit-tekst-v-fajl-v-unix-linux/</a></p>
  <p>Джокеры:</p>
  <p><a href="https://habr.com/ru/post/99827/" target="_blank">https://habr.com/ru/post/99827/</a></p>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex02</strong> (Z)</p>
  <p>Задание:</p>
  <p>• Create the following files and directories. Do what’s necessary so that when you use the <strong>ls -l</strong> command in your directory, the output will looks like this :</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/87/f3/87f3b4db-7743-4c91-9f7e-cfb8c1e9f27f.png" width="560" />
  </figure>
  <p>• Once you’ve done that, run tar -cf exo2.tar * to create the file to be submitted.</p>
  <p>• Создать файлы и директории с требуемым названием;</p>
  <p>• Задать им требуемые из скриншота свойства и размер в байтах</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/87/f3/87f3b4db-7743-4c91-9f7e-cfb8c1e9f27f.png" width="560" />
  </figure>
  <p>• Не беспокойтесь о том, что у вас вместо XX.</p>
  <p>• Год будет принят вместо времени на метке времени файла.</p>
  <p>Обратите внимание <strong>3</strong> и <strong>5</strong> связаны через <strong>Hard Link</strong> командой <strong>ln </strong>для созданияудаляем 5 файл и пишем команду <code>ln test3 test5</code> создается ссылка 5 указывающая на 3 файл. Тоже самое для <strong>0</strong> и <strong>6</strong> symbolic link <strong>ln</strong> -<strong>s </strong></p>
  <p><a href="https://ru.wikipedia.org/wiki/Ln_(Unix)" target="_blank">https://ru.wikipedia.org/wiki/Ln_(Unix)</a></p>
  <p>(Все необходимо заархивировать и удалить из папки все файлы! Должен остаться только архив <strong>exo2.tar</strong>)</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/17/fc/17fc2496-8637-4d49-bfd3-fac277058c32.png" width="1205" />
  </figure>
  <h2>Документация.</h2>
  <p>Создание Файлов и управление их временем:</p>
  <p><a href="https://itproffi.ru/sozdanie-fajlov-v-linux-komanda-touch/" target="_blank">https://itproffi.ru/sozdanie-fajlov-v-linux-komanda-touch/</a></p>
  <p>Установка прав чтения/записи/выполнения:</p>
  <p><a href="https://habr.com/ru/post/469667/" target="_blank">https://habr.com/ru/post/469667/</a></p>
  <p>Запись данных в файл:</p>
  <p><a href="https://linux-notes.org/vstavit-tekst-v-fajl-v-unix-linux/" target="_blank">https://linux-notes.org/vstavit-tekst-v-fajl-v-unix-linux/</a></p>
  <p>Джокеры:</p>
  <p><a href="https://habr.com/ru/post/99827/" target="_blank">https://habr.com/ru/post/99827/</a></p>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex03</strong> (klist.txt)</p>
  <p>Задание:</p>
  <p>• Make sure you have a valid (non-expired) Kerberos ticket. If you don’t have one yet, get one. </p>
  <p>• Once you’ve got at least one Kerberos ticket, write a list of all your tickets into a file named klist.txt</p>
  <p>• Создать (узнать) ключ кэширования Kerberos</p>
  <p>• Поместить его в klist.txt</p>
  <p>Создаете директорию <code>mkdir ex03</code></p>
  <p>Переходите в нее <code>cd ex03</code></p>
  <p>В командной стройке набираете <code>klist </code></p>
  <p>Записываем ключ через <code>vim</code> в файл <strong>klist.txt</strong></p>
  <h2>Документация</h2>
  <p>Справка по <strong>klist</strong> <a href="https://docs.microsoft.com/ru-ru/windows-server/administration/windows-commands/klist" target="_blank">https://docs.microsoft.com/ru-ru/windows-server/administration/windows-commands/klist</a></p>
  <p>Отображает список кэшированных в настоящее время билетов Kerberos</p>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex04</strong> (midLS)</p>
  <p>Задание:</p>
  <p>• In a midLS file, place the command line that will list all files and directories in your current directory (except for hidden files or any file that starts by a dot - yes, that includes double-dots), separated by a comma, by order of creation date. Make sure directories’ names are followed by a slash character.</p>
  <p>• В файле <code>midLS</code> поместите командную строку, в которой будут перечислены все файлы и каталоги в вашем текущем каталоге (кроме скрытых файлов или любого файла, начинающегося с точки - да, включая двойные точки), разделенных запятой, порядок создания даты. Убедитесь, что за именами каталогов следует косая черта.</p>
  <p>• То, о чем не просили, делать нельзя!</p>
  <p>• RTFM! (&quot;Read The Fucking Manual&quot; (Читай долбанное руководство).)</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/26/c3/26c35229-4c5c-46f5-a253-8a8035c3b117.png" width="1201" />
  </figure>
  <h2>Документация:</h2>
  <p>LS</p>
  <p><a href="https://losst.ru/komanda-ls-linux" target="_blank">https://losst.ru/komanda-ls-linux</a></p>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex05</strong> (git_commit.sh)</p>
  <p>Задание:</p>
  <p>• Create a shell script that displays the ids of the last 5 commits of your git repository.</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/da/6b/da6beb5f-dd07-47ea-8f52-0d07b2c296be.png" width="557" />
  </figure>
  <p>• Создайте сценарий оболочки, который отображает идентификаторы последних 5 коммитов вашего репозитория git:</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/da/6b/da6beb5f-dd07-47ea-8f52-0d07b2c296be.png" width="557" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/61/10/61105dd0-98a1-43c3-8396-f33d1ebf290f.png" width="1202" />
  </figure>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex06</strong> (git_ignore.sh)</p>
  <p>Задание:</p>
  <p>• In this exercice, you will write a short shell script that lists all the existing files ignored by your GiT repository. Example:</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/77/49/7749562c-7674-4d65-a5a9-836440153248.png" width="561" />
  </figure>
  <p>• В этом упражнении вы напишете короткий сценарий оболочки, который перечислит все существующие файлы, игнорируемые вашим репозиторием <code>Git</code>. Пример:</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/77/49/7749562c-7674-4d65-a5a9-836440153248.png" width="561" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/9c/b4/9cb4043f-849f-42d3-94b9-11ab12b59352.png" width="1204" />
  </figure>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex07</strong> (diff)</p>
  <p>Задание:</p>
  <p>• Create a file b, so that :</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/d9/2b/d92b60ae-03b7-4bd5-8030-cd1339d9f1b0.png" width="564" />
  </figure>
  <p>• Создайте файл <code>b</code>. Файлы для работы нам предоставляется файл <code>a</code> со старой версией файла и файл <code>sw.diff</code>, который хранит информацию о новых изменениях.</p>
  <p>• Содержимое файла <code>a</code> при просмотре его через программу <code>cat</code> с флагом <code>-e</code> будет выглядеть так:</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/d9/2b/d92b60ae-03b7-4bd5-8030-cd1339d9f1b0.png" width="564" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/8d/f0/8df00fcc-a248-404d-8df7-dd2bcd87eaa9.png" width="1205" />
  </figure>
  <pre data-lang="arduino">%&gt;cat -e ./b
Episode V, A NEW H0PE It is a period of civil war$
Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. $
During the battle, Rebel spies managed to steal secret plans to the Empire&#x27;s ultimate weapon, the STAR DEATH, an armored space station with enough power to destroy an entire planet.$
$
$
Pursued by the Empire&#x27;s sinister agents,$
Princess Mehdi races home aboard her starship, custodian of the stolen plans that can save her people and restore the dictatorship to the galaxie..$
$
$
$
$</pre>
  <figure class="m_original">
    <img src="https://teletype.in/files/54/e1/54e142ba-f545-43eb-b87a-0e452a496465.png" width="1206" />
  </figure>
  <h2>Документация:</h2>
  <p>man diff: <a href="https://ru.wikipedia.org/wiki/Diff" target="_blank">https://ru.wikipedia.org/wiki/Diff</a></p>
  <p>man patch: <a href="https://man7.org/linux/man-pages/man1/patch.1.html" target="_blank">https://man7.org/linux/man-pages/man1/patch.1.html</a></p>
  <p>Google.com</p>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex08</strong> (clean)</p>
  <p>Задание:</p>
  <p>• In a file called clean place the command line that will search for all files - in the current directory as well as in its sub-directories - with a name ending by ~, or a name that start and end by # </p>
  <p>• The command line will show and erase all files found. </p>
  <p>• Only one command is allowed: no ’;’ or ’&amp;&amp;’ or other shenanigans.</p>
  <p>• В файле с именем <code>clean</code> поместите командную строку, которая будет искать все файлы - в текущем каталоге, а также в его подкаталогах - заканчивая символом <code>~</code> и <code>/</code> или всеми файлами, которые начинаются или заканчиваются символом #. Командная строка покажет и удалит все найденные файлы. Допускается только одна команда: нельзя использовать <code>;</code> или <code>&amp;&amp;</code> или другие махинации.</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/24/24/24241b4d-93d2-4bfb-9535-2bc3c37a7eae.png" width="1203" />
  </figure>
  <h2>Документация:</h2>
  <p>man find</p>
  <p><a href="https://linux-faq.ru/page/komanda-file" target="_blank">https://linux-faq.ru/page/komanda-file</a></p>
  <p></p>
  <p>C Piscine Shell 00 <strong>ex09</strong> (ft_magic)</p>
  <p>Задание:</p>
  <p>• Create a magic file called ft_magic that will be formatted appropriately to detect files of 42 file type, built with a &quot;42&quot; string at the 42nd byte.</p>
  <p>• Создайте магический файл с именем <code>ft_magic</code>, который будет соответствующим образом отформатирован для обнаружения файлов с <code>42</code> типами файлов, построенных со строкой &quot;42&quot; в 42-м байте.</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/06/cd/06cd25f8-10f5-44af-a046-5b4cf5e3194f.png" width="1207" />
  </figure>
  <p>Команда для проверки:</p>
  <pre>    file -i ft_magic</pre>
  <p>Мы можем просмотреть шестнадцатеричный файл, введя следующую команду в терминале Linux:</p>
  <pre>    xdd ft_magic</pre>
  <p>Изменение магических номеров файла:</p>
  <pre>    hexedit ft_magic</pre>
  <h2>Документация:</h2>
  <p>man file</p>
  <p><a href="https://linux-faq.ru/page/komanda-file" target="_blank">https://linux-faq.ru/page/komanda-file</a></p>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/_gFB31wsly4</guid><link>https://teletype.in/@udarcs/_gFB31wsly4?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/_gFB31wsly4?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>C Piscine C 04</title><pubDate>Sun, 13 Jun 2021 16:56:28 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/dd/79/dd791dd4-62a8-4f7a-9256-02d0cee04d2a.png"></media:content><description><![CDATA[<img src="https://teletype.in/files/03/37/033770ca-611f-47cf-b296-13c41a6d4ad6.png"></img>Piscine C 03 ex00 (ft_strlen)]]></description><content:encoded><![CDATA[
  <p>Piscine C 03 <strong>ex00 </strong>(ft_strlen)</p>
  <p>Задание:</p>
  <p>• Create a function that counts and returns the number of characters in a string. • Here’s how it should be prototyped :</p>
  <p><code>int ft_strlen(char *str);</code></p>
  <p>• Создайте функцию, которая считает и возвращает количество символов в строке. • Вот как это должно быть объявлено:</p>
  <p><code>int ft_strlen(char *str);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">int    ft_strlen(char *str)
{
    int i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
        i++;
    return (i);
}
</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int    ft_strlen(char *str)
{
    int i;

    i = 0;
    while (*(str + i))
        i++;
    return (i);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int    ft_strlen(char *str)
{
    int n;

    n = 0;
    while (*str != &#x27;\0&#x27;)
    {
        str++;
        n++;
    }
    return (n);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/03/37/033770ca-611f-47cf-b296-13c41a6d4ad6.png" width="1191" />
  </figure>
  <p>Piscine C 03 <strong>ex01 </strong>(ft_putstr)</p>
  <p>Задание:</p>
  <p>• Create a function that displays a string of characters on the standard output. • Here’s how it should be prototyped :</p>
  <p><code>void ft_putstr(char *str);</code></p>
  <p>• Создайте функцию, которая отображает строку символов в стандартном выводе. • Вот как это должно быть объявлено:</p>
  <p><code>void ft_putstr(char *str);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_putstr(char *str)
{
    unsigned int    i;

    i = 0;
    while (*(str + i))
        i++;
    write(1, str, i);
}


/*        ИЛИ, тоже самое но, ТАК :
void    ft_putstr(char *str)
{
    unsigned int    i;
    i = 0;
    while (str[i])
        i++;
    write(1, str, i);
}
*/</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putstr(char *str)
{
    unsigned int    i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        ft_putchar(str[i]);
        i++;
    }
}

/*        ИЛИ, тоже самое но, ТАК :
void    ft_putstr(char *str)
{
    unsigned int i;
    i = 0;
    while (str[i])
        ft_putchar(str[i++]);
}
*/</pre>
  <p>Решение 3</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putstr(char *str)
{
    while (*str != &#x27;\0&#x27;)
    {
        ft_putchar(*str);
        str++;
    }
}

/*        ИЛИ, тоже самое но, ТАК :
void    ft_putstr(char *str)
{
    while (*str)
        ft_putchar(*str++);
}
*/</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/58/57/585708c9-682d-48c4-8f92-c4c35229ab51.png" width="1199" />
  </figure>
  <p>Piscine C 03 <strong>ex02 </strong>(ft_putnbr)</p>
  <p>Задание:</p>
  <p>• Create a function that displays the number entered as a parameter. The function has to be able to display all possible values within an int type variable. • Here’s how it should be prototyped :</p>
  <p><code>void ft_putnbr(int nb);</code></p>
  <p>• For example: <code>ft_putnbr(42)</code> displays &quot;42&quot;</p>
  <p>• Создайте функцию, которая отображает число, введенное в качестве параметра. Функция должна иметь возможность отображать все возможные значения в переменной типа int. • Вот как это должно быть объявлено:</p>
  <p><code>void ft_putnbr(int nb);</code></p>
  <p>• Например: <code>ft_putnbr(42)</code> displays &quot;42&quot;</p>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putnbr(int nb)
{
    int    temp;
    int    size;

    size = 1;
    if (nb &lt; 0)
    {
        ft_putchar(&#x27;-&#x27;);
        nb = -nb;
    }
    if (nb == -2147483648)
    {
        ft_putchar(&#x27;2&#x27;);
        nb = 147483648;
    }
    temp = nb;
    while ((temp /= 10) &gt; 0)
        size *= 10;
    temp = nb;
    while (size)
    {
        ft_putchar((char)((temp / size)) + 48);
        temp %= size;
        size /= 10;
    }
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putnbr(int n)
{
    if (n &lt; 0)
    {
        n = -n;
        ft_putchar(&#x27;-&#x27;);
    }
    if (n &gt;= 10)
        ft_putnbr(n / 10);
    ft_putchar((n % 10) + &#x27;0&#x27;);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putnbr(int nb)
{
    if (nb &lt; 0)
    {
        nb = -nb;
        ft_putchar(&#x27;-&#x27;);
    }
    if (nb &lt; 10)
        ft_putchar(nb + &#x27;0&#x27;);
    else
    {
        ft_putnbr(nb / 10);
        ft_putnbr(nb % 10);
    }
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/c1/4c/c14ced75-d153-4666-90f1-45d3e4dcd49c.png" width="1167" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/d2/46/d2465ae2-c7e1-45bf-a657-403359c572af.png" width="1211" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/35/d9/35d9fd53-3b7f-44a2-a760-30a936b19e4b.png" width="1155" />
  </figure>
  <p>Piscine C 03 <strong>ex03 </strong>(ft_putnbr)</p>
  <p>Задание:</p>
  <p>• Write a function that converts the initial portion of the string pointed by str to its int representation </p>
  <p>• The string can start with an arbitray amount of white space (as determined by isspace(3)) </p>
  <p>• The string can be followed by an arbitrary amount of + and - signs, - sign will change the sign of the int returned based on the number of - is odd or even. </p>
  <p>• Finally the string can be followed by any numbers of the base 10. </p>
  <p>• Your function should read the string until the string stop following the rules and return the number found until now. </p>
  <p>• You should not take care of overflow or underflow. result can be undefined in that case. </p>
  <p>• Here’s an example of a program that prints the atoi return value:</p>
  <p><code>$&gt;./a.out &quot; ---+--+1234ab567&quot; </code></p>
  <p><code>-1234</code></p>
  <p>• Напишите функцию, которая преобразует начальную часть строки, на которую указывает &#x27;str&#x27;, в ее представление &#x27;int&#x27; </p>
  <p>• Строка может начинаться с произвольного количества пробелов (как определено с помощью isspace (3)) </p>
  <p>• За строкой может следовать произвольное количество знаков &#x27;+&#x27; и &#x27;-&#x27;, знак &#x27;-&#x27; изменит знак возвращаемого целого числа &#x27;int&#x27; в зависимости от количества &#x27;-&#x27; нечетных или четных.</p>
  <p>• Наконец, за строкой могут следовать любые числа с основанием 10(десятичные). </p>
  <p>• Ваша функция должна читать строку до тех пор, пока она не перестанет следовать правилам и не вернет число, найденное до сих пор.</p>
  <p>• Не стоит заботиться о переполнении или опустошении. В этом случае результат может быть неопределенным.</p>
  <p>• Вот пример программы, которая печатает возвращаемое значение atoi:</p>
  <p><code>$&gt;./a.out &quot; ---+--+1234ab567&quot; </code></p>
  <p><code>-1234</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">int    ft_atoi(char *str)
{
    int    sign;
    int    num;

    sign = 1;
    num = 0;
    while ((*str == &#x27; &#x27;) || (*str == &#x27;\t&#x27;) || (*str == &#x27;\n&#x27;)
        || (*str == &#x27;\v&#x27;) || (*str == &#x27;\f&#x27;) || (*str == &#x27;\r&#x27;))
        str++;
    if (*str == &#x27;-&#x27;)
        sign = -1;
    while ((*str == &#x27;-&#x27;) || (*str == &#x27;+&#x27;))
        str++;
    while (*str &gt;= &#x27;0&#x27; &amp;&amp; *str &lt;= &#x27;9&#x27;)
    {
        num = (num * 10) + ((int)*str - &#x27;0&#x27;);
        str++;
    }
    return (num * sign);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int            ft_atoi(char *str)
{
    int        v;
    int        n;

    n = 0;
    if (*str == &#x27;-&#x27;)
    {
        str++;
        n = 1;
    }
    v = 0;
    while (*str != &#x27;\0&#x27;)
    {
        if (*str &gt;= &#x27;0&#x27; &amp;&amp; *str &lt;= &#x27;9&#x27;)
            v = (v * 10) + (*str - &#x27;0&#x27;);
        else
            return (0);
        str++;
    }
    return ((v &gt; 0 &amp;&amp; n) ? -v : v);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int    ft_atoi(char *str)
{
    int    x;
    int total;
    int is_negative;

    is_negative = 0;
    x = 0;
    total = 0;
    while (str[x] == &#x27; &#x27; || str[x] == &#x27;\n&#x27; || str[x] == &#x27;\r&#x27; || str[x] == &#x27;\f&#x27;
            || str[x] == &#x27;\t&#x27; || str[x] == &#x27;\v&#x27; || str[x] == &#x27;+&#x27;)
        x++;
    if (str[x] == &#x27;-&#x27;)
    {
        is_negative = 1;
        x++;
    }
    while ((str[x] == &#x27;-&#x27;) || (str[x] == &#x27;+&#x27;))
        x++;
    while (str[x] &gt;= &#x27;0&#x27; &amp;&amp; str[x] &lt;= &#x27;9&#x27;)
    {
        total *= 10;
        total += ((int)str[x] - 48);
        x++;
    }
    if (is_negative)
        return (-total);
    else
        return (total);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">int    ft_atoi(char *str)
{
    int    x;
    int total;
    int is_negative;

    is_negative = 0;
    x = 0;
    total = 0;
    while (str[x] == &#x27; &#x27; || str[x] == &#x27;\n&#x27; || str[x] == &#x27;\r&#x27; || str[x] == &#x27;\f&#x27;
            || str[x] == &#x27;\t&#x27; || str[x] == &#x27;\v&#x27; || str[x] == &#x27;+&#x27;)
        x++;
    if (str[x] == &#x27;-&#x27;)
    {
        is_negative = 1;
        x++;
    }
    while ((str[x] == &#x27;-&#x27;) || (str[x] == &#x27;+&#x27;))
        x++;
    while (str[x] &gt;= &#x27;0&#x27; &amp;&amp; str[x] &lt;= &#x27;9&#x27;)
    {
        total *= 10;
        total += ((int)str[x] - 48);
        x++;
    }
    if (is_negative)
        return (-total);
    else
        return (total);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/35/c0/35c0ffa7-581d-4696-9ff3-d7e21cca4c5f.png" width="1173" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/f4/39/f439838c-addf-4b47-911c-73086ebed9f8.png" width="1185" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/75/b6/75b69187-f421-4742-bb21-a25e80c444b5.png" width="1178" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/41/86/4186932f-2e69-4a15-8f94-1d7bf0822662.png" width="1177" />
  </figure>
  <p>Piscine C 04 <strong>ex04 </strong>(ft_putnbr_base)</p>
  <p>Задание:</p>
  <p>• Create a function that displays a number in a base system in the terminal. • This number is given in the shape of an int, and the radix in the shape of a string of characters. • The base-system contains all useable symbols to display that number : ◦ 0123456789 is the commonly used base system to represent decimal numbers ◦ 01 is a binary base system ; ◦ 0123456789ABCDEF an hexadecimal base system ; ◦ poneyvif is an octal base system. • The function must handle negative numbers. • If there’s an invalid argument, nothing should be displayed. Examples of invalid arguments : ◦ base is empty or size of 1; ◦ base contains the same character twice ; ◦ base contains + or - ; • Here’s how it should be prototyped :</p>
  <p><code>void ft_putnbr_base(int nbr, char *base);</code></p>
  <p>• Создайте функцию, которая отображает число в нужной базовой системе счисления на экране.</p>
  <p>• В аргументах функции это число дается нам в форме целого числа, а система счисления дается нам - в виде &#x27;строки символов&#x27;.</p>
  <p>• Базовая система счисления содержит все используемые символы для отображения этого числа:</p>
  <p>  - 0123456789 - широко используемая базовая десятична система для представления десятичных чисел;</p>
  <p>  - 01 - двоичная базовая система;</p>
  <p>  - 0123456789ABCDEF шестнадцатеричная базовая система;</p>
  <p>  - poneyvif - это восьмеричная базовая система.</p>
  <p>• Функция должна обрабатывать отрицательные числа.</p>
  <p>• Если указан неверный аргумент, ничего не должно отображаться. Примеры неверных аргументов:</p>
  <p>  - Если база, отражающая систему счисления, пуста или имеет размер 1;</p>
  <p>  - Если база, отражающая систему счисления, содержит один и тот же символ дважды;</p>
  <p>  - Если база, отражающая систему счисления, содержит символы &#x27;+&#x27; или &#x27;-&#x27;;</p>
  <p>  - и т. д.</p>
  <p><code>void ft_putnbr_base(int nbr, char *base);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/ab/74/ab74b84e-73a2-48aa-b23d-73531f5e111d.png" width="580" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">int    ft_atoi(char *str)
{
    int    x;
    int total;
    int is_negative;

    is_negative = 0;
    x = 0;
    total = 0;
    while (str[x] == &#x27; &#x27; || str[x] == &#x27;\n&#x27; || str[x] == &#x27;\r&#x27; || str[x] == &#x27;\f&#x27;
            || str[x] == &#x27;\t&#x27; || str[x] == &#x27;\v&#x27; || str[x] == &#x27;+&#x27;)
        x++;
    if (str[x] == &#x27;-&#x27;)
    {
        is_negative = 1;
        x++;
    }
    while ((str[x] == &#x27;-&#x27;) || (str[x] == &#x27;+&#x27;))
        x++;
    while (str[x] &gt;= &#x27;0&#x27; &amp;&amp; str[x] &lt;= &#x27;9&#x27;)
    {
        total *= 10;
        total += ((int)str[x] - 48);
        x++;
    }
    if (is_negative)
        return (-total);
    else
        return (total);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void        ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

static int    ft_check_base(char *base)
{
    int    i;
    int    z;

    i = 0;
    if (!base || !base[1])
        return (0);
    while (base[i])
    {
        if (!((base[i] &gt;= &#x27;0&#x27; &amp;&amp; base[i] &lt;= &#x27;9&#x27;) || (base[i] &gt;= &#x27;a&#x27; \
                &amp;&amp; base[i] &lt;= &#x27;z&#x27;) || (base[i] &gt;= &#x27;A&#x27; &amp;&amp; base[i] &lt;= &#x27;Z&#x27;)))
            return (0);
        z = i + 1;
        while (base[z])
        {
            if (base[i] == base[z])
                return (0);
            z++;
        }
        i++;
    }
    return (i);
}


int        ft_get_len_future_nbr(int nbr, int base_type)
{
    int    size;

    if (base_type)
    {
        size = 1;
        while ((nbr /= base_type) &gt; 0)
            size++;
    }
    return (size);
}

void    ft_conv_nbr(int nbr, int length, char *base, int base_type)
{
    int        i;
    int        n[length];

    i = 0;
    while (nbr)
    {
        n[i] = nbr % base_type;
        nbr /= base_type;
        i++;
    }
    while (i &gt; 0)
        ft_putchar(base[n[--i]]);
    
}


void    ft_putnbr_base(int nbr, char *base)
{
    int        base_type;

    if ((base_type = ft_check_base(base)))
    {
        if (nbr &lt; 0)
        {
            nbr = -nbr;
            ft_putchar(&#x27;-&#x27;);
        }
        ft_conv_nbr(nbr, ft_get_len_future_nbr(nbr, base_type), base, base_type);
    }
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}


int        ft_check_base(char *base)
{
    int    i;
    int    z;

    i = 0;
    z = 0;
    if (base[0] == &#x27;\0&#x27; || base[1] == &#x27;\0&#x27;)
        return (0);
    while (base[i])
    {
        z = i + 1;
        if (base[i] == &#x27;+&#x27; || base[i] == &#x27;-&#x27;)
            return (0);
        if (base[i] &lt; 32 || base[i] &gt; 126)
            return (0);
        while (base[z])
        {
            if (base[i] == base[z])
                return (0);
            z++;
        }
        i++;
    }
    return (i);
}

void    ft_putnbr_base(int nbr, char *base)
{
    int    base_type;
    int    nbr_final[100];
    int    i;

    i = 0;
    if ((base_type = ft_check_base(base)))
    {
        if (nbr &lt; 0)
        {
            nbr = -nbr;
            ft_putchar(&#x27;-&#x27;);
        }
        while (nbr)
        {
            nbr_final[i] = nbr % base_type;
            nbr = nbr / base_type;
            i++;
        }
        while (--i &gt;= 0)
            ft_putchar(base[nbr_final[i]]);
    }
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}


static int    ft_strlen(char *str)
{
    int len;

    len = 0;
    while (*str++ != &#x27;\0&#x27;)
    {
        len++;
    }
    return (len);
}

static void    ft_putnbr_base_n(int nbr, char *base, int n)
{
    if (nbr &lt; 0)
    {
        ft_putchar(&#x27;-&#x27;);
        if (nbr == -2147483648)
        {
            ft_putnbr_base_n(2, base, n);
            ft_putnbr_base_n(147483648, base, n);
        }
        else
            ft_putnbr_base_n(-nbr, base, n);
    }
    else if (nbr &lt; n)
        ft_putchar(base[nbr]);
    else
    {
        ft_putnbr_base_n(nbr / n, base, n);
        ft_putchar(base[nbr % n]);
    }
}

static int    ft_strchar(char *str, char to_find)
{
    while (*str != &#x27;\0&#x27;)
        if (to_find == *str++)
            return (1);
    return (0);
}

static int    ft_check_base(char *base, int n)
{
    while (n)
    {
        if (base[n] == &#x27;+&#x27; || base[n] == &#x27;-&#x27;)
            return (0);
        if (ft_strchar(base + n + 1, base[n]))
            return (0);
        --n;
    }
    return (1);
}

void        ft_putnbr_base(int nbr, char *base)
{
    int        base_len;

    base_len = ft_strlen(base);
    if (base &amp;&amp; (base_len &gt; 1) &amp;&amp; ft_check_base(base, base_len))
        ft_putnbr_base_n(nbr, base, base_len);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/26/c8/26c81ce1-f23d-4d05-b0ab-6d71c89bbd26.png" width="1179" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/dc/cc/dccc5fb5-04b9-42ff-9c1a-f1701aa8936a.png" width="1185" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/0e/f4/0ef42728-c1af-4415-a9cc-ca5a841f53ee.png" width="1178" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/2c/b5/2cb5b067-0cd6-4990-9826-70614c03b443.png" width="1188" />
  </figure>
  <p>Piscine C 04 <strong>ex05 </strong>(ft_atoi_base)</p>
  <p>Задание:</p>
  <p>• Write a function that converts the initial portion of the string pointed by str to int representation. </p>
  <p>• str is in a specific base given as a second parameter. </p>
  <p>• excepted the base rule, the function should work exactly like ft_atoi. </p>
  <p>• If there’s an invalid argument, the function should return 0. Examples of invalid arguments : </p>
  <p>   ◦ base is empty or size of 1; </p>
  <p>   ◦ base contains the same character twice ; </p>
  <p>   ◦ base contains + or - or whitespaces; </p>
  <p>• Here’s how it should be prototyped :</p>
  <p><code>int ft_atoi_base(char *str, char *base);</code></p>
  <p>• Напишите функцию, которая преобразует начальную часть строки, на которую указывает &#x27;str&#x27;, в целое число &#x27;int&#x27;.</p>
  <p>• Строка символов &#x27;str&#x27; представляет собой число в определенной системе счисления, заданной во втором параметре.</p>
  <p>• За исключением базового правила, функция должна работать точно так же, как и функция &#x27;ft_atoi&#x27;.</p>
  <p>• Если указан неверный аргумент, функция должна вернуть 0. Примеры неверных аргументов:</p>
  <p>   ◦ Если база, отражающая систему счисления, пуста или имеет размер 1;</p>
  <p>   ◦ Если база, отражающая систему счисления, содержит один и тот же символ дважды;</p>
  <p>   ◦ Если база, отражающая систему счисления, содержит символы &#x27;+&#x27; или &#x27;-&#x27;;</p>
  <p><code>int ft_atoi_base(char *str, char *base);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/a3/64/a364e70a-3556-4eba-a137-d09845d3833c.png" width="576" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">int        ft_ctoi(char c)
{
    if (c &gt;= &#x27;0&#x27; &amp;&amp; c &lt;= &#x27;9&#x27;)
        return (c - &#x27;0&#x27;);
    if (c &gt;= &#x27;A&#x27; &amp;&amp; c &lt;= &#x27;F&#x27;)
        return (c - &#x27;A&#x27; + 10);
    if (c &gt;= &#x27;a&#x27; &amp;&amp; c &lt;= &#x27;f&#x27;)
        return (c - &#x27;a&#x27; + 10);
    return (-1);
}



int        ft_pow(int nb, int power)
{
    int    result;

    result = 1;
    if(power &lt; 0)
        return (0);
    if(power == 0)
        return (1);
    while (power--)
        result *= nb;
    return (result);
}



int        ft_check_base(char *base)
{
    int    i;
    int    z;

    i = 0;
    z = 0;
    if (!base || !base[1])
        return (0);
    while (base[i])
    {
        z = i + 1;
        if (!((base[i] &gt;= &#x27;0&#x27; &amp;&amp; base[i] &lt;= &#x27;9&#x27;) || (base[i] &gt;= &#x27;a&#x27; \
                &amp;&amp; base[i] &lt;= &#x27;z&#x27;) || (base[i] &gt;= &#x27;A&#x27; &amp;&amp; base[i] &lt;= &#x27;Z&#x27;)))
            return (0);
        while (base[z])
        {
            if (base[i] == base[z])
                return (0);
            z++;
        }
        i++;
    }
    return (i);
}



int        ft_atoi_base(char *str, char *base)
{
    int        num;
    int        negative;
    int        i;
    int        pow;
    int        base_type;

    negative = 1;
    i = 0;
    if((base_type = ft_check_base(base)))
    {
        if (*str == &#x27;-&#x27;)
        {
            i++;
            negative = -1;
        }
        while (str[i])
            i++;
        pow = 0;
        num = 0;
        while (--i &gt;= 0)
        {
            if ((ft_ctoi(str[i]) != -1) &amp;&amp; (ft_ctoi(str[i]) &lt; base_type))
                num += ft_ctoi(str[i]) * ft_pow(base_type, pow++);
        }
        return (num * negative);
    }
    return (0);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">static int    ft_isspace(int c)
{
    return (c == &#x27;\t&#x27; || c == &#x27;\n&#x27; || c == &#x27;\v&#x27; || c == &#x27;\f&#x27; || c == &#x27;\r&#x27;
        || c == &#x27; &#x27;);
}

static int    ft_strlen(char *str)
{
    int        i;

    i = 0;
    while (str[i])
        i++;
    return (i);
}

static int    ft_find_char(char c, char *str)
{
    int i;

    i = 0;
    while (str[i] &amp;&amp; str[i] != c)
        i++;
    return (i);
}

int            ft_atoi_base(char *str, char *base)
{
    int        result;
    int        neg;
    int        base_len;

    result = 0;
    base_len = ft_strlen(base);
    if (base_len &lt; 2)
        return (0);
    while (ft_isspace(*str))
        str++;
    neg = *str == &#x27;-&#x27;;
    str += (*str == &#x27;+&#x27; || *str == &#x27;-&#x27;) ? 1 : 0;
    while (ft_find_char(*str, base) &lt; base_len)
        result = result * base_len - ft_find_char(*str++, base);
    return (neg ? result : -result);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        is_pr3(char c)
{
    return (c &gt;= 32 &amp;&amp; c &lt;= 126);
}

int        is_space3(char c)
{
    return ((c &gt;= 9 &amp;&amp; c &lt;= 13) || c == &#x27; &#x27;);
}

int        validate_base3(char *base)
{
    char    *ptr;
    int        i;
    int        vals[95];

    ptr = base;
    i = -1;
    while (i++ &lt; 95)
        vals[i] = 0;
    i = 0;
    while (*ptr)
    {
        if (!is_pr3(*ptr))
            return (0);
        if (*ptr == &#x27;+&#x27; || *ptr == &#x27;-&#x27;)
            return (0);
        if (vals[(*ptr) - 32])
            return (0);
        vals[(*ptr) - 32] = 1;
        i++;
        ptr++;
    }
    if (i &lt; 2)
        return (0);
    return (i);
}

int        parse_positive(char *str, char *base, int basen)
{
    char    *ptr;
    int        i;
    int        v;

    v = 0;
    while (*str)
    {
        i = 0;
        ptr = base;
        while (*ptr)
        {
            if (*str == *ptr)
                break ;
            i++;
            ptr++;
        }
        if (i &gt;= basen)
            break ;
        v *= basen;
        v -= i;
        str++;
    }
    return (v);
}

int        ft_atoi_base(char *str, char *base)
{
    int        basen;
    int        v;
    int        is_positive;

    if (!(basen = validate_base3(base)))
        return (0);
    is_positive = 0;
    while (is_space3(*str))
        str++;
    if (*str == &#x27;+&#x27; || *str == &#x27;-&#x27;)
    {
        is_positive = -1;
        if (*str == &#x27;+&#x27;)
            is_positive = 1;
        str++;
    }
    v = parse_positive(str, base, basen);
    v *= -(is_positive + !is_positive);
    return (v);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/0b/c8/0bc8f522-5db4-448b-8be1-27ddd0b255bd.png" width="1176" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/0f/0f/0f0f770b-32d1-46d6-bb10-e461bd210b23.png" width="1180" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/61/6b/616ba394-bfbe-4d5b-872b-266576f1d688.png" width="1179" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/7b/b0/7bb076ca-6880-4427-92ad-6506e04ad086.png" width="1176" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/60/15/60155e3f-259f-4490-a8ff-7fd93e09668d.png" width="1187" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/1b/51/1b51ae6b-c75c-4109-ae55-39d571f8cf3c.png" width="1174" />
  </figure>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/1Vj-ZU-8r0F</guid><link>https://teletype.in/@udarcs/1Vj-ZU-8r0F?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/1Vj-ZU-8r0F?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>C Piscine C 03</title><pubDate>Sun, 13 Jun 2021 16:51:12 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/b1/24/b1247740-8cdf-49bd-9a92-9f01e5139942.png"></media:content><description><![CDATA[<img src="https://teletype.in/files/70/c0/70c0a7fa-f7c8-465f-b861-79c87a5d8c6f.png"></img>Piscine C 03 ex00 (ft_strcpy)]]></description><content:encoded><![CDATA[
  <p>Piscine C 03 <strong>ex00 </strong>(ft_strcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strcmp (man strcmp). • Here’s how it should be prototyped :</p>
  <p><code>int ft_strcmp(char *s1, char *s2);</code></p>
  <p>• Воспроизвести поведение функции strcmp (man strcmp). • Вот как это должно быть объявлено:</p>
  <p><code>int ft_strcmp(char *s1, char *s2);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/70/c0/70c0a7fa-f7c8-465f-b861-79c87a5d8c6f.png" width="591" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">int        ft_strcmp(char *s1, char *s2)
{
    while (*s1 &amp;&amp; (*s1 == *s2))
    {
        s1++;
        s2++;
    }
    return (*s1 - *s2);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int    ft_strcmp(char *s1, char *s2)
{
    int i;

    i = 0;
    while (s1[i] &amp;&amp; (s1[i] == s2[i]))
    {
        i++;
    }
    return (s1[i] - s2[i]);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        ft_strcmp(char *s1, char *s2)
{
    while (*s1++ == *s2++)
        if (*s1 == &#x27;\0&#x27; &amp;&amp; *s2 == &#x27;\0&#x27;)
            return (0);
    return (*--s1 - *--s2);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">int    ft_strcmp(char *s1, char *s2)
{
    int i;

    i = 0;
    while (s1[i] == s2[i])
    {
        if (s1[i] == &#x27;\0&#x27; &amp;&amp; s2[i] == &#x27;\0&#x27;)
            return (0);
        i++;
    }
    return (s1[i] - s2[i]);
}</pre>
  <p>Решение 5</p>
  <pre data-lang="c">int ft_strcmp(char *s1, char *s2)
{
    int    i;

    i = 0;
    while (s1[i] || s2[i])
    {
        if (s1[i] != s2[i])
            return (s1[i] - s2[i]);
        i++;
    }
    return (0);
}</pre>
  <p>Решение 6</p>
  <pre data-lang="c">int    ft_strcmp(char *s1, char *s2)
{
    int    i;

    i = 0;
    while (s1[i] || s2[i])
    {
        if (s1[i] &lt; s2[i])
            return (-1);
        if (s1[i] &gt; s2[i])
            return (1);
        i++;
    }
    return (0);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/8e/69/8e693776-0163-4d5e-a7db-1fc28153f74f.png" width="1126" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/bd/ec/bdecb4fc-a89f-4a05-9ab9-e882a7ebf7df.png" width="1115" />
  </figure>
  <p>Piscine C 03 <strong>ex01 </strong>(ft_strcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strncmp (man strncmp). • Here’s how it should be prototyped :</p>
  <p><code>int ft_strncmp(char *s1, char *s2, unsigned int n);</code></p>
  <p>• Воспроизвести поведение функции strncmp (man strncmp) • Вот как это должно быть объявлено:</p>
  <p><code>int ft_strncmp(char *s1, char *s2, unsigned int n);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/87/e7/87e774c1-da19-4574-a2e2-083463bb76e6.png" width="572" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">int    ft_strcmp(char *s1, char *s2)
{
    int    i;

    i = 0;
    while (s1[i] || s2[i])
    {
        if (s1[i] &lt; s2[i])
            return (-1);
        if (s1[i] &gt; s2[i])
            return (1);
        i++;
    }
    return (0);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int        ft_strncmp(char *s1, char *s2, unsigned int n)
{
    int    i;

    i = 0;
    while (i &lt; n)
    {
        if (*s1 != *s2)
            return (*s1 - *s2);
        if (*s1 == &#x27;\0&#x27; &amp;&amp; *s2 == &#x27;\0&#x27;)
            return (0);
        *s1++;
        *s2++;
        i++;
    }
    return (0);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        ft_strncmp(char *s1, char *s2, unsigned int n)
{
    unsigned int i;

    i = 1;
    while (*s1++ == *s2++)
    {
        if (i &gt;= n)
            return (0);
        if (*s1 == &#x27;\0&#x27; &amp;&amp; *s2 == &#x27;\0&#x27;)
            return (0);
        i++;
    }
    return (*--s1 - *--s2);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/b0/b0/b0b0a57f-8103-4532-af4f-3047d7df013c.png" width="1086" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/28/8b/288b2efe-9496-4897-a7bb-dab8194dbee0.png" width="1190" />
  </figure>
  <p>Piscine C 03 <strong>ex02 </strong>(ft_strcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strcat (man strcat). • Here’s how it should be prototyped :</p>
  <p><code>char *ft_strcat(char *dest, char *src);</code></p>
  <p>Воспроизведите поведение функции strcat (man strcat). • Вот как это должно быть объявлено:</p>
  <p><code>char *ft_strcat(char *dest, char *src);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/77/8a/778aa9f6-0a67-4245-86cc-172a1f8fc46e.png" width="604" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">char    *ft_strcat(char *dest, char *src)
{
    int    i;
    int    dest_size;

    i = 0;
    dest_size = 0;
    while (dest[dest_size])
        dest_size++;
    while (src[i])
    {
        dest[dest_size] = src[i];
        dest_size++;
        i++;
    }
    dest[dest_size] = &#x27;\0&#x27;;
    return (dest);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">char    *ft_strcat(char *dest, char *src)
{
    char    *ptr;

    ptr = dest;
    while (*dest)
        dest++;
    while (*src)
        *dest++ = *src++;
    *dest = &#x27;\0&#x27;;
    return (ptr);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">char    *ft_strcat(char *dest, char *src)
{
    int i;
    int lenght;

    i = 0;
    lenght = 0;
    while (dest[i] != &#x27;\0&#x27;)
    {
        lenght++;
        i++;
    }
    i = 0;
    while (src[i] != &#x27;\0&#x27;)
    {
        dest[lenght + i] = src[i];
        i++;
    }
    dest[lenght + i] = &#x27;\0&#x27;;
    return (dest);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/03/0a/030a4a11-aaf9-4005-899a-f17833af068d.png" width="1191" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/d1/db/d1dbd202-57ca-4d62-94e5-fd9a429f7135.png" width="1038" />
  </figure>
  <p>Piscine C 03 <strong>ex03 </strong>(ft_strcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strncat (man strncat). • Here’s how it should be prototyped :</p>
  <p><code>char *ft_strncat(char *dest, char *src, unsigned int nb);</code></p>
  <p>• Воспроизведите поведение функции strncat (man strncat). • Вот как это должно быть объявлено:</p>
  <p><code>char *ft_strncat(char *dest, char *src, unsigned int nb);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/0f/fc/0ffc8d7e-6830-4963-ac87-07ace6b41d68.png" width="612" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">char    *ft_strncat(char *dest, char *src, int nb)
{
    int    i;
    int    dest_size;

    i = 0;
    dest_size = 0;
    while (dest[dest_size] != &#x27;\0&#x27;)
        dest_size++;
    while (i &lt; nb &amp;&amp; src[i] != &#x27;\0&#x27;)
    {
        dest[dest_size] = src[i];
        dest_size++;
        i++;
    }
    dest[dest_size] = &#x27;\0&#x27;;
    return (dest);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">char    *ft_strncat(char *dest, char *src, int nb)
{
    int i;
    int lenght;

    i = 0;
    lenght = 0;
    while (dest[lenght] != &#x27;\0&#x27;)
        lenght++;
    while (i &lt; nb &amp;&amp; src[i] != &#x27;\0&#x27;)
    {
        dest[lenght] = src[i];
        lenght++;
        i++;
    }
    dest[lenght] = &#x27;\0&#x27;;
    return (dest);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">char    *ft_strncat(char *dest, char *src, int nb)
{
    int i;
    int x;

    i = 0;
    x = 0;
    while (dest[i] != &#x27;\0&#x27;)
        i++;
    while (src[x] != &#x27;\0&#x27; &amp;&amp; x &lt; nb)
    {
        dest[i] = src[x];
        i++;
        x++;
    }
    dest[i] = &#x27;\0&#x27;;
    return (dest);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">char    *ft_strncat(char *dest, char *src, int nb)
{
    int        i;
    int        j;

    i = 0;
    j = 0;
    while (dest[i])
        i++;
    while ((j &lt; nb) &amp;&amp; src[j])
    {
        dest[i + j] = src[j];
        j++;
    }
    dest[i + j] = &#x27;\0&#x27;;
    return (dest);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/b5/c2/b5c261c4-65ef-4214-8678-d926ae78af8b.png" width="1166" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/77/d1/77d16b50-37e2-488e-954b-aabf28680d57.png" width="1136" />
  </figure>
  <p>Piscine C 03 <strong>ex04 </strong>(ft_strcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strstr (man strstr). • Here’s how it should be prototyped :</p>
  <p><code>char *ft_strstr(char *str, char *to_find);</code></p>
  <p>• Воспроизвести поведение функции strstr (man strstr). • Вот как это должно быть объявлено:</p>
  <p><code>char *ft_strstr(char *str, char *to_find);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/86/1f/861f2a04-1408-435f-b357-890d8de30702.png" width="618" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">char    *ft_strstr(char *str, char *to_find)
{
    int    i;
    int    j;

    i = 0;
    if (to_find[0] == &#x27;\0&#x27;)
        return (str);
    while (str[i])
    {
        j = 0;
        while (str[i + j] == to_find[j])
        {
            if (to_find[j + 1] == &#x27;\0&#x27;)
                return (str + i);
            j++;
        }
        i++;
    }
    return ((void *)0);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">char    *ft_strstr(char *str, char *to_find)
{
    char    *a;
    char    *b;

    b = to_find;
    if (*b == &#x27;\0&#x27;)
        return (str);
    while (*str)
    {
        if (*str == *b)
        {
            a = str;
            while (*a == *b || *b == &#x27;\0&#x27;)
            {
                if (*b == &#x27;\0&#x27;)
                    return (str);
                a++;
                b++;
            }
            b = to_find;
        }
        str++;
    }
    return (0);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">char    *ft_strstr(char *str, char *to_find)
{
    int        i;
    int        y;
    char    *occurrence;

    occurrence = 0;
    if (to_find[0] == &#x27;\0&#x27;)
        return (str);
    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] == to_find[0])
        {
            occurrence = str + i;
            y = 0;
            while (str[i + y] == to_find[y])
            {
                if (to_find[y + 1] == &#x27;\0&#x27;)
                    return (occurrence);
                y++;
            }
            occurrence = 0;
        }
        i++;
    }
    return (0);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/a7/cd/a7cdc3be-8c3b-459a-a77c-5fd0c79a97b7.png" width="879" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/62/e6/62e6751d-f0ea-4207-b2e5-f03cd94b698f.png" width="1164" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/c1/54/c1546127-6b7f-45dc-94d3-fa1438ea414e.png" width="1138" />
  </figure>
  <p>Piscine C 03 <strong>ex04 </strong>(ft_strcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strlcat (man strlcat). • Here’s how it should be prototyped :</p>
  <p><code>unsigned int ft_strlcat(char *dest, char *src, unsigned int size);</code></p>
  <p>• Воспроизведите поведение функции strlcat (man strlcat). • Вот как это должно быть объявлено:</p>
  <p><code>unsigned int ft_strlcat(char *dest, char *src, unsigned int size);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/6d/e0/6de0a309-6909-4a69-a105-dda75ee2ee74.png" width="602" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">unsigned int    ft_strlcat(char *dest, char *src, unsigned int size)
{
    int                i;
    unsigned int    dest_size;

    i = 0;
    dest_size = 0;
    while (dest[dest_size])
        dest_size++;
    while (src[i] &amp;&amp; (dest_size &lt; (size - 1)))
    {
        dest[dest_size] = src[i];
        dest_size++;
        i++;
    }
    dest[dest_size] = &#x27;\0&#x27;;
    return (dest_size);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">static int        ft_strlen(char *str)
{
    int        i;

    i = 0;
    while (str[i])
        i += 1;
    return (i);
}

unsigned int    ft_strlcat(char *dst, char *src, unsigned int size)
{
    int        i;
    int        len;

    i = 0;
    len = 0;
    while (dst[len] &amp;&amp; len &lt; size)
        len++;
    i = len;
    while (src[len - i] &amp;&amp; len + 1 &lt; size)
    {
        dst[len] = src[len - i];
        len++;
    }
    if (i &lt; size)
        dst[len] = &#x27;\0&#x27;;
    return (i + ft_strlen(src));
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/08/f2/08f29384-e8b4-47f1-91dc-c8531ed158e7.png" width="1160" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/02/c3/02c3e50f-38a5-4666-8277-0a27e72131e1.png" width="1208" />
  </figure>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/LXj3R5xw7K1</guid><link>https://teletype.in/@udarcs/LXj3R5xw7K1?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/LXj3R5xw7K1?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>C Piscine C 02</title><pubDate>Sun, 13 Jun 2021 15:27:32 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/cf/1f/cf1f3237-d0b3-4b83-bca1-cc72efaccfa6.png"></media:content><description><![CDATA[<img src="https://teletype.in/files/a5/ea/a5eadec5-f4ca-471a-9713-48d6311a1a32.png"></img>Piscine C 02 ex00 (ft_strcpy)]]></description><content:encoded><![CDATA[
  <p>Piscine C 02 <strong>ex00 </strong>(ft_strcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strcpy (man strcpy). • Here’s how it should be prototyped :</p>
  <p><code>char *ft_strcpy(char *dest, char *src);</code></p>
  <p>• Воспроизведите поведение функции strcpy (man strcpy). • Вот как это должно быть объявлено:</p>
  <p><code>char *ft_strcpy(char *dest, char *src);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/a5/ea/a5eadec5-f4ca-471a-9713-48d6311a1a32.png" width="578" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">char    *ft_strcpy(char *dest, char *src)
{
    int    i;

    i = 0;
    while (src[i])
    {
        dest[i] = src[i];
        i++;
    }
    dest[i] = &#x27;\0&#x27;;
    return (dest);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">char    *ft_strcpy(char *dest, char *src)
{
    char *tmp;

    tmp = dest;
    while (*src)
    {
        *dest = *src;
        dest++;
        src++;
    }
    *dest = &#x27;\0&#x27;;
    return (tmp);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">char    *ft_strcpy(char *dest, char *src)
{
    char    *t;

    t = dest;
    while ((*t++ = *src++) != 0)
        ;
    return (dest);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">char    *ft_strcpy(char *dest, char *src)
{
    int i;

    i = 0;
    while (src[i] != &#x27;\0&#x27;)
    {
        dest[i] = src[i];
        i++;
    }
    dest[i] = &#x27;\0&#x27;;
    return (dest);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/76/81/76811c80-40e6-4c98-93ba-ca22aea3cbd6.png" width="994" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/fe/e1/fee197c2-5360-4e49-8b73-dc4c8afc1c7e.png" width="1178" />
  </figure>
  <p>Piscine C 02 <strong>ex01 </strong>(ft_strcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strncpy (man strncpy). • Here’s how it should be prototyped :</p>
  <p><code>char *ft_strncpy(char *dest, char *src, unsigned int n);</code></p>
  <p>• Воспроизвести поведение функции strncpy (man strncpy). • Вот как это должно быть объявлено:</p>
  <p><code>char *ft_strncpy(char *dest, char *src, unsigned int n);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/48/2a/482a59aa-4416-4164-9194-57197cf6f2bc.png" width="609" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">char    *ft_strncpy(char *dest, char *src, unsigned int n)
{
    unsigned int    i;
    int             size;

    size = 0;
    i = 0;
    while (i &lt; n &amp;&amp; src[i])
    {
        dest[i] = src[i];
        i++;
    }
    while (i &lt; n)
    {
        dest[i] = &#x27;\0&#x27;;
        i++;
    }
    return (dest);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">char    *ft_strncpy(char *dest, char *src, unsigned int n)
{
    unsigned int i;

    i = 0;
    while ((src[i] != &#x27;\0&#x27;) &amp;&amp; (i &lt; n))
    {
        dest[i] = src[i];
        i++;
    }
    while ((dest[i] != &#x27;\0&#x27;) &amp;&amp; (i &lt; n))
    {
        dest[i] = &#x27;\0&#x27;;
        i++;
    }
    return (dest);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/53/ac/53ac03bf-2ea6-423e-9552-5d53cdf91473.png" width="1209" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/a1/7d/a17dedea-5588-414a-91e8-0366dd47715b.png" width="1195" />
  </figure>
  <p>Piscine C 02 <strong>ex02 </strong>(ft_str_is_alpha)</p>
  <p>Задание:</p>
  <p>• Create a function that returns 1 if the string given as a parameter contains only alphabetical characters, and 0 if it contains any other character. • Here’s how it should be prototyped :</p>
  <p><code>int ft_str_is_alpha(char *str);</code></p>
  <p>• It should return 1 if str is empty.</p>
  <p>• Создайте функцию, которая возвращает 1, если строка, заданная в качестве параметра, содержит только алфавитные символы, и 0, если она содержит еще и любой другой символ. </p>
  <p><code>int ft_str_is_alpha(char *str);</code></p>
  <p>• Функция должна возвращать 1, если str пуст(не содержит др символов).</p>
  <p>Решение 1</p>
  <pre data-lang="c">int        iss_alpha(char c)
{
    if ((c &gt;= &#x27;a&#x27;) &amp;&amp; (c &lt;= &#x27;z&#x27;))
        return (1);
    if ((c &gt;= &#x27;A&#x27;) &amp;&amp; (c &lt;= &#x27;Z&#x27;))
        return (1);
    return (0);
}

int        ft_str_is_alpha(char *str)
{
    int    i;
    
    i = 0;
    while (str[i])
    {
        if (!(iss_alpha(str[i])))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int        iss_alpha(char c)
{
    return (((c &gt;= &#x27;a&#x27;) &amp;&amp; (c &lt;= &#x27;z&#x27;)) || ((c &gt;= &#x27;A&#x27;) &amp;&amp; (c &lt;= &#x27;Z&#x27;)));
}

int        ft_str_is_alpha(char *str)
{
    int    i;
    
    i = 0;
    while (str[i])
    {
        if (!(iss_alpha(str[i])))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        ft_str_is_alpha(char *str)
{
    int        i;
    char    c;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        c = str[i];
        if (!((c &gt;= &#x27;A&#x27; &amp;&amp; c &lt;= &#x27;Z&#x27;) || (c &gt;= &#x27;a&#x27; &amp;&amp; c &lt;= &#x27;z&#x27;)))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">int        ft_str_is_alpha(char *str)
{
    int    i;
    int    b;

    b = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if ((str[i] &gt;= &#x27;a&#x27; &amp;&amp; str[i] &lt;= &#x27;z&#x27;) ||
            (str[i] &gt;= &#x27;A&#x27; &amp;&amp; str[i] &lt;= &#x27;Z&#x27;))
            b = 1;
        else
            return (0);
        i++;
    }
    return (b);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/93/ed/93ed6af8-cb45-498d-9efc-d3b100eebd84.png" width="941" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/7a/f2/7af22648-75c1-4899-8ffc-3338864acaa7.png" width="1153" />
  </figure>
  <p>Piscine C 02 <strong>ex03 </strong>(ft_str_is_numeric)</p>
  <p>Задание:</p>
  <p>• Create a function that returns 1 if the string given as a parameter contains only digits, and 0 if it contains any other character. • Here’s how it should be prototyped :</p>
  <p><code>int ft_str_is_numeric(char *str);</code></p>
  <p>• It should return 1 if str is empty.</p>
  <p>• Создайте функцию, которая возвращает 1, если строка, заданная в качестве параметра, содержит только цифры, и 0, если она содержит любой другой символ. </p>
  <p><code>int ft_str_is_numeric(char *str);</code></p>
  <p>• Функция должна возвращать 1, если str пуст(не содержит др символов).</p>
  <p>Решение 1</p>
  <pre data-lang="c">int        iss_num(char c)
{
    return ((c &gt;= &#x27;0&#x27;) &amp;&amp; (c &lt;= &#x27;9&#x27;));
}

int        ft_str_is_numeric(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if (!(iss_num(str[i])))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int        iss_num(char c)
{
    if ((c &gt;= &#x27;0&#x27;) &amp;&amp; (c &lt;= &#x27;9&#x27;))
        return (1);
    return (0);
}

int        ft_str_is_numeric(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if (!(iss_num(str[i])))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        ft_str_is_numeric(char *str)
{
    int    i;
    int    b;

    b = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= &#x27;0&#x27; &amp;&amp; str[i] &lt;= &#x27;9&#x27;)
            b = 1;
        else
            return (0);
        i++;
    }
    return (b);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">int        ft_str_is_numeric(char *str)
{
    int        i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (!(str[i] &gt;= 48 &amp;&amp; str[i] &lt;= 57))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/ea/f3/eaf3e55d-7947-4296-840c-074e28ea08d2.png" width="963" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/7f/31/7f31f99c-cf55-463a-899c-82185a26604e.png" width="1165" />
  </figure>
  <p>Piscine C 02 <strong>ex04 </strong>(ft_str_is_lowercase)</p>
  <p>Задание:</p>
  <p>• Create a function that returns 1 if the string given as a parameter contains only lowercase alphabetical characters, and 0 if it contains any other character. • Here’s how it should be prototyped :</p>
  <p><code>int ft_str_is_lowercase(char *str);</code></p>
  <p>• It should return 1 if str is empty.</p>
  <p>Создайте функцию, которая возвращает 1, если строка, заданная в качестве параметра, содержит только строчные буквенные символы, и 0, если она содержит любой другой символ</p>
  <p><code>int ft_str_is_lowercase(char *str);</code></p>
  <p>• Функция должна возвращать 1, если строка &#x27;str&#x27; пуста (не содержит др символов).</p>
  <p>Решение 1</p>
  <pre data-lang="c">int        ft_str_is_lowercase(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if (!((str[i] &gt;= &#x27;a&#x27;) &amp;&amp; (str[i] &lt;= &#x27;z&#x27;)))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int        iss_lowercase(char c)
{
    if ((c &gt;= &#x27;a&#x27;) &amp;&amp; (c &lt;= &#x27;z&#x27;))
        return (1);
    return (0);
}

int        ft_str_is_lowercase(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if (!(iss_lowercase(str[i])))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        ft_str_is_lowercase(char *str)
{
    int    i;
    int    b;

    b = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= &#x27;a&#x27; &amp;&amp; str[i] &lt;= &#x27;z&#x27;)
            b = 1;
        else
            return (0);
        i++;
    }
    return (b);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">int        ft_str_is_lowercase(char *str)
{
    int        i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (!(str[i] &gt;= 97 &amp;&amp; str[i] &lt;= 122))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/51/14/51142291-2acd-485e-bd6d-170d1cac3354.png" width="1193" />
  </figure>
  <p>Piscine C 02 <strong>ex05</strong> (ft_str_is_uppercase)</p>
  <p>Задание:</p>
  <p>• Create a function that returns 1 if the string given as a parameter contains only uppercase alphabetical characters, and 0 if it contains any other character. • Here’s how it should be prototyped :</p>
  <p><code>int ft_str_is_uppercase(char *str);</code></p>
  <p>• It should return 1 if str is empty.</p>
  <p>• Создайте функцию, которая возвращает 1, если строка, заданная в качестве параметра, содержит только заглавные буквенные символы, и 0, если она содержит любой другой символ.</p>
  <p><code>int ft_str_is_uppercase(char *str);</code></p>
  <p>• Функция должна возвращать 1, если str пуст(не содержит др символов).</p>
  <p>Решение 1</p>
  <pre data-lang="c">int        ft_str_is_uppercase(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if (!((str[i] &gt;= &#x27;A&#x27;) &amp;&amp; (str[i] &lt;= &#x27;Z&#x27;)))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int        iss_uppercase(char c)
{
    if ((c &gt;= &#x27;A&#x27;) &amp;&amp; (c &lt;= &#x27;Z&#x27;))
        return (1);
    return (0);
}

int    ft_str_is_uppercase(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if (!(iss_uppercase(str[i])))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        ft_str_is_uppercase(char *str)
{
    int    i;
    int    b;

    b = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= &#x27;A&#x27; &amp;&amp; str[i] &lt;= &#x27;Z&#x27;)
            b = 1;
        else
            return (0);
        i++;
    }
    return (b);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">int        ft_str_is_uppercase(char *str)
{
    int        i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (!(str[i] &gt;= 65 &amp;&amp; str[i] &lt;= 90))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/70/3e/703ef888-774a-4021-bf42-352bc07ee5bd.png" width="1173" />
  </figure>
  <p>Piscine C 02 <strong>ex06</strong> (ft_str_is_printable)</p>
  <p>Задание:</p>
  <p>• Create a function that returns 1 if the string given as a parameter contains only printable characters, and 0 if it contains any other character. • Here’s how it should be prototyped :</p>
  <p><code>int ft_str_is_printable(char *str);</code></p>
  <p>• It should return 1 if str is empty</p>
  <p>• Создайте функцию, которая возвращает 1, если строка, заданная в качестве параметра, содержит только печатные символы, и 0, если она содержит любой другой символ.</p>
  <p><code>int ft_str_is_printable(char *str);</code></p>
  <p>• Функция должна возвращать 1, если строка str пуста(не содержит др символов).</p>
  <p>Решение 1</p>
  <pre data-lang="c">int        ft_str_is_printable(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if (!((str[i] &gt;= 32) &amp;&amp; (str[i] &lt;= 126)))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int        iss_printable(char c)
{
    return ((c &gt;= 32) &amp;&amp; (c &lt;= 126));
}

int        ft_str_is_printable(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if (!(iss_printable(str[i])))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        ft_str_is_printable(char *str)
{
    int    i;
    int    b;

    b = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= &#x27; &#x27; &amp;&amp; str[i] &lt;= &#x27;~&#x27;)
            b = 1;
        else
            return (0);
        i++;
    }
    return (b);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">int        ft_str_is_printable(char *str)
{
    int        i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (!(str[i] &gt;= 32 &amp;&amp; str[i] &lt;= 126))
            return (0);
        i++;
    }
    return (1);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/d1/bc/d1bc0f13-8e2f-4416-ad50-71678ca33349.png" width="882" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/ba/94/ba942e6d-9d99-4a0c-89a7-813cee8603c3.png" width="1146" />
  </figure>
  <p>Piscine C 02 <strong>ex07 </strong>(ft_strupcase)</p>
  <p>Задание:</p>
  <p>• Create a function that transforms every letter to uppercase. • Here’s how it should be prototyped :</p>
  <p><code>char *ft_strupcase(char *str);</code></p>
  <p>• It should return str</p>
  <p>• Создать функцию, которая преобразует каждую букву каждого слова в верхний регистр. • Вот как это должно быть объявлено:</p>
  <p><code>char *ft_strupcase(char *str);</code></p>
  <p>•Функция должна вернуть строку.</p>
  <p>Решение 1</p>
  <pre data-lang="c">char    *ft_strupcase(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if ((str[i] &gt;= &#x27;a&#x27;) &amp;&amp; (str[i] &lt;= &#x27;z&#x27;))
            str[i] = ((str[i] - &#x27;a&#x27;) + &#x27;A&#x27;);
        i++;
    }
    return (str);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">char *ft_strupcase(char *str)
{
    int i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= &#x27;a&#x27; &amp;&amp; str[i] &lt;= &#x27;z&#x27;)
            str[i] = ((str[i] - &#x27;a&#x27;) + &#x27;A&#x27;);
        i++;
    }
    return (str);
}
</pre>
  <p>Решение 3</p>
  <pre data-lang="c">char    *ft_strupcase(char *str)
{
    int i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= 97 &amp;&amp; str[i] &lt;= 122)
            str[i] = str[i] - 32;
        i++;
    }
    return (str);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">char    *ft_struppcase(char *str)
{
    char *p;

    p = str;
    while (*p)
    {
        if ((*p &gt;= &#x27;a&#x27;) &amp;&amp; (*p &lt;= &#x27;z&#x27;))
            *p = ((*p - &#x27;a&#x27;) + &#x27;A&#x27;);
        p++;
    }
    return (str);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/3c/9b/3c9b271b-2e1d-4dd0-be92-cadd0ecb6535.png" width="1187" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/f5/c8/f5c81c06-fafb-407e-bdbe-6bcfacf5c478.png" width="1169" />
  </figure>
  <p>Piscine C 02 <strong>ex08 </strong>(ft_strupcase)</p>
  <p>Задание:</p>
  <p>• Create a function that transforms every letter to lowercase. • Here’s how it should be prototyped :</p>
  <p><code>char *ft_strlowcase(char *str);</code></p>
  <p>• It should return str.</p>
  <p>• Создать функцию, которая преобразует каждую букву каждого слова в нижний регистр. • Вот как это должно быть объявлено:</p>
  <p><code>char *ft_strlowcase(char *str);</code></p>
  <p>• Функция должна вернуть строку.</p>
  <p>Решение 1</p>
  <pre data-lang="c">char    *ft_strlowcase(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        if ((str[i] &gt;= &#x27;A&#x27;) &amp;&amp; (str[i] &lt;= &#x27;Z&#x27;))
            str[i] = str[i] + 32;
        i++;
    }
    return (str);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">char *ft_strlowcase(char *str)
{
    int i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= &#x27;A&#x27; &amp;&amp; str[i] &lt;= &#x27;Z&#x27;)
            str[i] = str[i] - &#x27;A&#x27; + &#x27;a&#x27;;
        i++;
    }
    return (str);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">char    *ft_strlowcase(char *str)
{
    int i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= 65 &amp;&amp; str[i] &lt;= 90)
            str[i] = str[i] + 32;
        i++;
    }
    return (str);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/0c/de/0cdeefe7-58a2-4a2a-bc4a-a6b8ac2fd6ab.png" width="1210" />
  </figure>
  <p>Piscine C 02 <strong>ex09 </strong>(ft_strupcase)</p>
  <p>Задание:</p>
  <p>• Create a function that capitalizes the first letter of each word and transforms all other letters to lowercase. • A word is a string of alphanumeric characters. • Here’s how it should be prototyped :</p>
  <p><code>char *ft_strcapitalize(char *str);</code></p>
  <p>• It should return str. • For example:</p>
  <p>salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un</p>
  <p>• Becomes:</p>
  <p>Salut, Comment Tu Vas ? 42mots Quarante-Deux; Cinquante+Et+U</p>
  <p>• Создайте функцию, которая делает первую букву каждого слова заглавной и преобразует все остальные буквы в строчные. • Слово - это строка буквенно-цифровых символов. • Вот как это должно быть объявлено:</p>
  <p><code>char *ft_strcapitalize(char *str);</code></p>
  <p>• Функция должна вернуть строку.</p>
  <p>• Например это:</p>
  <p>salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un</p>
  <p>• Становится этим:</p>
  <p>Salut, Comment Tu Vas ? 42mots Quarante-Deux; Cinquante+Et+U</p>
  <p>Решение 1</p>
  <pre data-lang="c">int        iss_alpha(char c)
{
    if ((c &gt;= &#x27;a&#x27;) &amp;&amp; (c &lt;= &#x27;z&#x27;))
        return (1);
    if ((c &gt;= &#x27;A&#x27;) &amp;&amp; (c &lt;= &#x27;Z&#x27;))
        return (1);
    if ((c &gt;= &#x27;0&#x27;) &amp;&amp; (c &lt;= &#x27;9&#x27;))
        return (1);
    return (0);
}

int        is_maj(char c)
{
    return ((c &gt;= &#x27;A&#x27;) &amp;&amp; (c &lt;= &#x27;Z&#x27;));
}

char    is_min(char c)
{
    return ((c &gt;= &#x27;a&#x27;) &amp;&amp; (c &lt;= &#x27;z&#x27;));
}

char    *ft_strcapitalize(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        while (str[i] &amp;&amp; !iss_alpha(str[i]))
            i++;
        if (str[i] &amp;&amp; is_min(str[i]))
            str[i] = ((str[i] - &#x27;a&#x27;) + &#x27;A&#x27;);
        i++;
        while (str[i] &amp;&amp; iss_alpha(str[i]))
        {
            if (is_maj(str[i]))
                str[i] = ((str[i] - &#x27;A&#x27;) + &#x27;a&#x27;);
            i++;
        }
    }
    return (str);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int        iss_alpha(char c)
{
    if ((c &gt;= &#x27;a&#x27;) &amp;&amp; (c &lt;= &#x27;z&#x27;))
        return (1);
    if ((c &gt;= &#x27;A&#x27;) &amp;&amp; (c &lt;= &#x27;Z&#x27;))
        return (1);
    if ((c &gt;= &#x27;0&#x27;) &amp;&amp; (c &lt;= &#x27;9&#x27;))
        return (1);
    return (0);
}

char    *ft_strcapitalize(char *str)
{
    int    i;

    i = 0;
    while (str[i])
    {
        while (str[i] &amp;&amp; !iss_alpha(str[i]))
            i++;
        if (str[i] &amp;&amp; ((str[i] &gt;= &#x27;a&#x27;) &amp;&amp; (str[i] &lt;= &#x27;z&#x27;)))
            str[i] = ((str[i] - &#x27;a&#x27;) + &#x27;A&#x27;);
        i++;
        while (str[i] &amp;&amp; iss_alpha(str[i]))
        {
            if ((str[i] &gt;= &#x27;A&#x27;) &amp;&amp; (str[i] &lt;= &#x27;Z&#x27;))
                str[i] = ((str[i] - &#x27;A&#x27;) + &#x27;a&#x27;);
            i++;
        }
    }
    return (str);
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        iss_alpha(char c)
{
    if ((c &gt;= &#x27;a&#x27;) &amp;&amp; (c &lt;= &#x27;z&#x27;))
        return (1);
    if ((c &gt;= &#x27;A&#x27;) &amp;&amp; (c &lt;= &#x27;Z&#x27;))
        return (1);
    if ((c &gt;= &#x27;0&#x27;) &amp;&amp; (c &lt;= &#x27;9&#x27;))
        return (1);
    return (0);
}

int        is_maj(char c)
{
    return ((c &gt;= &#x27;A&#x27;) &amp;&amp; (c &lt;= &#x27;Z&#x27;));
}

char    is_min(char c)
{
    return ((c &gt;= &#x27;a&#x27;) &amp;&amp; (c &lt;= &#x27;z&#x27;));
}

char    *ft_strcapitalize(char *str)
{
    int    i;
    int    word_new;

    i = 0;
    word_new = 1;
    while (str[i])
    {
        if (is_min(str[i]) &amp;&amp; (word_new == 1))
            str[i] = ((str[i] - &#x27;a&#x27;) + &#x27;A&#x27;);
        else if (is_maj(str[i]) &amp;&amp; (word_new == 0))
            str[i] = ((str[i] - &#x27;A&#x27;) + &#x27;a&#x27;);
        if (iss_alpha(str[i]))
            word_new = 0;
        else
            word_new = 1;
        i++;
    }
    return (str);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">char    *jp_strlowcase(char *str)
{
    int    i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if (str[i] &gt;= &#x27;A&#x27; &amp;&amp; str[i] &lt;= &#x27;Z&#x27;)
            str[i] = ((str[i] - &#x27;A&#x27;) + &#x27;a&#x27;);
        i++;
    }
    return (str);
}

char    *ft_strcapitalize(char *str)
{
    int    i;

    i = 1;
    jp_strlowcase(str);
    if (str[0] &gt;= &#x27;a&#x27; &amp;&amp; str[0] &lt;= &#x27;z&#x27;)
        str[0] = ((str[0] - &#x27;a&#x27;) + &#x27;A&#x27;);
    while (str[i])
    {
        if ((str[i] &gt;= &#x27; &#x27; &amp;&amp; str[i] &lt;= &#x27;/&#x27;) ||
            (str[i] &gt;= &#x27;:&#x27; &amp;&amp; str[i] &lt;= &#x27;@&#x27;))
            if (str[i + 1] &gt;= &#x27;a&#x27; &amp;&amp; str[i + 1] &lt;= &#x27;z&#x27;)
                str[i + 1] = ((str[i + 1] - &#x27;a&#x27;) + &#x27;A&#x27;);
        i++;
    }
    return (str);
}</pre>
  <p>Решение 5</p>
  <pre data-lang="c">char    *ft_strcapitalize(char *str)
{
    int        i;
    char    c;
    int        space;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        space = 1;
        if (i == 0)
            c = &#x27;;&#x27;;
        else
            c = str[i - 1];
        if ((c &gt;= &#x27;A&#x27; &amp;&amp; c &lt;= &#x27;Z&#x27;) || (c &gt;= &#x27;a&#x27; &amp;&amp; c &lt;= &#x27;z&#x27;))
            space = 0;
        if (c &gt;= &#x27;0&#x27; &amp;&amp; c &lt;= &#x27;9&#x27;)
            space = 0;
        if (space == 1 &amp;&amp; str[i] &gt;= &#x27;a&#x27; &amp;&amp; str[i] &lt;= &#x27;z&#x27;)
            str[i] = str[i] - 32;
        if (space == 0 &amp;&amp; str[i] &gt;= &#x27;A&#x27; &amp;&amp; str[i] &lt;= &#x27;Z&#x27;)
            str[i] = str[i] + 32;
        i++;
    }
    return (str);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/aa/a4/aaa416c5-55cc-4275-8449-c65c3c029a08.png" width="1147" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/fe/2f/fe2fe1dc-5aea-4952-aa0e-8a5669f4482c.png" width="1211" />
  </figure>
  <p>Piscine C 02 <strong>ex10</strong> (ft_strlcpy)</p>
  <p>Задание:</p>
  <p>• Reproduce the behavior of the function strlcpy (man strlcpy). • Here’s how it should be prototyped :</p>
  <p><code>unsigned int ft_strlcpy(char *dest, char *src, unsigned int size);</code></p>
  <p>• Воспроизведите поведение функции strlcpy (man strlcpy).• Вот как это должно быть объявлено:</p>
  <p><code>unsigned int ft_strlcpy(char *dest, char *src, unsigned int size);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/8f/36/8f36e045-7ab8-4859-9c2b-27caaf742941.png" width="558" />
  </figure>
  <pre data-lang="c">unsigned int    ft_strlcpy(char *dest, char *src, unsigned int size)
{
    unsigned int    i;

    i = 0;
    size -= 1;
    while (src[i] &amp;&amp; (i &lt; size))
    {
        dest[i] = src[i];
        i++;
    }
    dest[i] = &#x27;\0&#x27;;
    return (i);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/d3/d8/d3d8fa23-de0c-4809-bb4a-da3d1750cf0a.png" width="1191" />
  </figure>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/Yz117IvnPQB</guid><link>https://teletype.in/@udarcs/Yz117IvnPQB?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/Yz117IvnPQB?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>Piscine C 01</title><pubDate>Sun, 13 Jun 2021 14:15:37 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/74/af/74af8df3-31b8-4e0a-9ecc-557589e3e62c.png"></media:content><description><![CDATA[<img src="https://teletype.in/files/19/ce/19ce0e88-3ff6-47d1-8b15-e99155046116.png"></img>Piscine C 01 ex00 (ft_ft)]]></description><content:encoded><![CDATA[
  <p>Piscine C 01 <strong>ex00 </strong>(ft_ft)</p>
  <p>Задание:</p>
  <p>• Create a function that takes a pointer to int as a parameter, and sets the value &quot;42&quot; to that int. • Here’s how it should be prototyped : <code>void ft_ft(int *nbr);</code></p>
  <p>• Создайте функцию, которая принимает указатель на &#x27;int&#x27; в качестве параметра и задает значение &quot;42&quot; для этого &#x27;int&#x27;. • Вот как это должно быть объявлено: <code>void ft_ft(int *nbr);</code></p>
  <p>Разрешенные функции: отсутствуют</p>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_ft(int *nbr)
{
    *nbr = 42;
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void        ft_ft(int *nbr)
{
    *nbr = 42;
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/19/ce/19ce0e88-3ff6-47d1-8b15-e99155046116.png" width="860" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/a4/55/a455fa0f-3afb-411a-81d6-1a3df34e0330.png" width="1025" />
  </figure>
  <p>Piscine C 01 <strong>ex01 </strong>(ft_ultimate_ft)</p>
  <p>Задание:</p>
  <p>• Create a function that takes a pointer to pointer to pointer to pointer to pointer to pointer to pointer to pointer to pointer to int as a parameter and sets the value &quot;42&quot; to that int. • Here’s how it should be prototyped : </p>
  <p><code>void ft_ultimate_ft(int *********nbr);</code></p>
  <p>• Создайте функцию, которая принимает &quot;указатель на указатель на указатель на указатель на указатель на указатель на указатель на указатель на указатель на указатель на указатель&quot; на &#x27;int&#x27; в качестве параметра и устанавливает значение    &quot; 42 &quot; для этого &#x27;int&#x27;. • Вот как это должно быть объявлено:</p>
  <p><code>void ft_ultimate_ft(int *********nbr);</code></p>
  <pre data-lang="c">void    ft_ultimate_ft(int *********nbr)
{
    *********nbr = 42;
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/f2/7b/f27ba76c-a671-4725-bae0-023577bd8c43.png" width="922" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/dc/01/dc01ce5a-4def-4b92-937f-97fcbb0a25cd.png" width="1092" />
  </figure>
  <p>Piscine C 01 <strong>ex02 </strong>(ft_swap)</p>
  <p>Задание:</p>
  <p>• Create a function that swaps the value of two integers whose addresses are entered as parameters. • Here’s how it should be prototyped :</p>
  <p><code>void ft_swap(int *a, int *b);</code></p>
  <p>• Создайте функцию, которая меняет местами значения двух целых чисел, адреса которых вводятся в качестве параметров. • Вот как это должно быть объявлено:</p>
  <p><code>oid ft_swap(int *a, int *b);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_swap(int *a, int *b)
{
    int    temp;

    temp = *a;
    *a = *b;
    *b = temp;
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void        ft_swap(int *a, int *b)
{
    int t;

    t = *a;
    *a = *b;
    *b = t;
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">void    ft_swap(int *a, int *b)
{
    int    c;

    c = *a;
    *a = *b;
    *b = c;
}
</pre>
  <p>Решение 4</p>
  <pre data-lang="c">void    ft_swap(int *a, int *b)
{
    int        tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/2a/1a/2a1a18a1-6370-4ea8-af11-d5890b51df66.png" width="885" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/af/7a/af7aa588-09aa-4132-b068-7cdae11f69a0.png" width="1068" />
  </figure>
  <p>Piscine C 01 <strong>ex03 </strong>(ft_div_mod)</p>
  <p>Задание:</p>
  <p>• Create a function ft_div_mod prototyped like this :</p>
  <p><code>void ft_div_mod(int a, int b, int *div, int *mod);</code></p>
  <p>• This function divides parameters a by b and stores the result in the int pointed by div. It also stores the remainder of the division of a by b in the int pointed by mod.</p>
  <p>• Эта функция делит параметров &#x27;а&#x27;, &#x27;b&#x27; и сохраняет результат в переменной типа &#x27;int&#x27;, на который указывает элемент &#x27;div&#x27;. Он также хранит остаток деления &#x27;a&#x27; на &#x27;b&#x27; в &#x27;int&#x27;, указанном &#x27;mod&#x27;. • Вот как это должно быть объявлено.</p>
  <p><code>void ft_div_mod(int a, int b, int *div, int *mod);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_div_mod(int a, int b, int *div, int *mod)
{
    *div = a / b;
    *mod = a % b;
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void        ft_div_mod(int a, int b, int *div, int *mod)
{
    if (b != 0)
    {
        *div = a / b;
        *mod = a % b;
    }
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">void    ft_div_mod(int a, int b, int *div, int *mod)
{
    *div = a / b;
    *mod = a % b;
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">void    ft_div_mod(int a, int b, int *div, int *mod)
{
    *div = a / b;
    *mod = a % b;
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/2a/eb/2aebbf2d-262f-4bbb-aa74-c7716ef1a4ce.png" width="901" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/88/23/8823bae6-72af-48f0-b065-297213ccabd0.png" width="939" />
  </figure>
  <p>Piscine C 01 <strong>ex04 </strong>(ft_ultimate_div_mod)</p>
  <p>Задание:</p>
  <p>• Create a function ft_ultimate_div_mod with the following prototype :</p>
  <p><code>void ft_ultimate_div_mod(int *a, int *b);</code></p>
  <p>• This function divides parameters a by b. The result of this division is stored in the int pointed by a. The remainder of the division is stored in the int pointed by b.</p>
  <p>• Эта функция делит параметры &#x27;a&#x27; на &#x27;b&#x27;. результат этого деления сохраняется в &#x27;int&#x27;, указанном &#x27;a&#x27;. Остаток от деления хранится в переменной типа &#x27;int&#x27; указывает на &#x27;b&#x27;. • Вот как это должно быть объявлено:</p>
  <p><code>void ft_ultimate_div_mod(int *a, int *b);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_ultimate_div_mod(int *a, int *b)
{
    int    temp;

    temp = *a;
    *a = *a / *b;
    *b = temp % *b;
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void        ft_ultimate_div_mod(int *a, int *b)
{
    int t;

    if (b != 0)
    {
        t = *a;
        *a = *a / *b;
        *b = t % *b;
    }
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">void    ft_ultimate_div_mod(int *a, int *b)
{
    int c;
    int d;

    c = *a;
    d = *b;
    *a = c / d;
    *b = c % d;
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">void    ft_ultimate_div_mod(int *a, int *b)
{
    int div;
    int mod;

    div = *a / *b;
    mod = *a % *b;
    *a = div;
    *b = mod;
}</pre>
  <p>Решение 5</p>
  <pre data-lang="c">void    ft_ultimate_div_mod(int *a, int *b)
{
    int        tmp;

    tmp = *a;
    *a /= *b;
    *b = tmp % *b;
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/a8/76/a876ef0d-f0ac-4195-b72b-7522bcf93a54.png" width="903" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/04/f5/04f57c03-e353-4480-b400-84e0e36d964b.png" width="1026" />
  </figure>
  <p>Piscine C 01 <strong>ex05</strong> (ft_putstr)</p>
  <p>Задание:</p>
  <p>• Create a function that displays a string of characters on the standard output. • Here’s how it should be prototyped :</p>
  <p><code>void ft_putstr(char *str);</code></p>
  <p>• Создайте функцию, которая отображает строку символов в стандартном выводе. • Вот как это должно быть объявлено: </p>
  <p><code>void ft_putstr(char *str);</code></p>
  <p>Разрешенные функции: write</p>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_putstr(char *str)
{
    unsigned int    i;

    i = 0;
    while (*(str + i))
        i++;
    write(1, str, i);
}


/*        ИЛИ, тоже самое но, ТАК :
void    ft_putstr(char *str)
{
    unsigned int    i;
    i = 0;
    while (str[i])
        i++;
    write(1, str, i);
}
*/</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putstr(char *str)
{
    unsigned int    i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        ft_putchar(str[i]);
        i++;
    }
}

/*        ИЛИ, тоже самое но, ТАК :
void    ft_putstr(char *str)
{
    unsigned int i;
    i = 0;
    while (str[i])
        ft_putchar(str[i++]);
}
*/
</pre>
  <p>Решение 3</p>
  <pre data-lang="c">void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putstr(char *str)
{
    while (*str != &#x27;\0&#x27;)
    {
        ft_putchar(*str);
        str++;
    }
}

/*        ИЛИ, тоже самое но, ТАК :
void    ft_putstr(char *str)
{
    while (*str)
        ft_putchar(*str++);
}
*/
</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/1b/1a/1b1ae20a-c55e-4bf8-af4f-904cb0300b63.png" width="1194" />
  </figure>
  <p>Piscine C 01 <strong>ex06</strong> (ft_strlen)</p>
  <p>Задание:</p>
  <p>• Create a function that counts and returns the number of characters in a string. • Here’s how it should be prototyped :</p>
  <p><code>int ft_strlen(char *str);</code></p>
  <p>• Создайте функцию, которая подсчитывает и возвращает количество символов в строке. • Вот как это должно быть обьявлено:</p>
  <p><code>int ft_strlen(char *str);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">int        ft_strlen(char *str)
{
    int n;

    n = 0;
    while (str[n] != &#x27;\0&#x27;)
    {
        n++;
    }
    return (n);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">int        ft_strlen(char *str)
{
    int n;

    n = 0;
    while (1)
    {
        if (str[n] == &#x27;\0&#x27;)
        {
            return (n);
        }
        n++;
    }
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">int        ft_strlen(char *str)
{
    int count;

    count = 0;
    while (*str != &#x27;\0&#x27;)
    {
        count++;
        str++;
    }
    return (count);
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">int        ft_strlen(char *str)
{
    int        i;

    i = 0;
    while (str[i])
        i += 1;
    return (i);
}</pre>
  <p>Решение 5</p>
  <pre data-lang="c">int        ft_strlen(char *str)
{
    int    i;

    i = 0;
    while (str[i])
        i++;
    return (i);
}</pre>
  <p>Решение 6</p>
  <pre data-lang="c">int        ft_strlen(char *str)
{
    int l;

    l = 0;
    while (*str++ != &#x27;\0&#x27;)
        l++;
    return (l);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/ce/f6/cef63dc1-0e5d-4382-b30b-308bc9df3abc.png" width="1010" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/ec/bb/ecbb9c2b-a498-4d77-b907-56edb0f2251c.png" width="1196" />
  </figure>
  <p>Piscine C 01 <strong>ex07</strong> (ft_rev_int_tab)</p>
  <p>Задание:</p>
  <p>• Create a function which reverses a given array of integer (first goes last, etc). • The arguments are a pointer to int and the number of ints in the array. • Here’s how it should be prototyped :</p>
  <p><code>void ft_rev_int_tab(int *tab, int size);</code></p>
  <p>• Создайте функцию, которая переворачивает данный массив целых чисел (первый элемент массива станет последним, и т.д.). • Аргументами будут указатель на адрес первого элемента массива целых чисел типа &#x27;int&#x27; и количество целых чисел в этом массиве. • Вот как это должно быть объявлено:</p>
  <p><code>void ft_rev_int_tab(int *tab, int size);</code></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/f0/a4/f0a42080-8f62-4a43-8561-d536c13ffb09.png" width="485" />
  </figure>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_rev_int_tab(int *tab, int size)
{
    int        i;
    char    temp;

    i = -1;
    while (++i &lt; --size)
    {
        temp = tab[i];
        tab[i] = tab[size];
        tab[size] = temp;
    }
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void    ft_rev_int_tab(int *tab, int size)
{
    int        counter;
    char    temp;

    counter = 0;
    while (counter &lt; size - 1)
    {
        temp = tab[size];
        tab[size] = tab[counter];
        tab[counter] = temp;
        counter++;
        size--;
    }
}
</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/aa/0a/aa0abff9-b4a1-4a18-a38b-5b6d799b2153.png" width="969" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/1e/3e/1e3e0f5e-50d6-474e-8c0d-c20e23d7c2e9.png" width="1194" />
  </figure>
  <p>Piscine C 01 <strong>ex08</strong> (ft_sort_int_tab)</p>
  <p>Задание:</p>
  <p>• Create a function which sorts an array of integers by ascending order. • The arguments are a pointer to int and the number of ints in the array. • Here’s how it should be prototyped :</p>
  <p><code>void ft_sort_int_tab(int *tab, int size);</code></p>
  <p>• Создайте функцию, которая сортирует массив (таблицу) целых чисел по возрастанию. • Аргументами являются указатель на int и число ints в поле массив. • Вот как это должно быть объявлено:</p>
  <p><code>void ft_sort_int_tab(int *tab, int size);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">void    ft_sort_int_tab(int *tab, int size)
{
    int i;
    int j;
    int temp;

    i = 0;
    while (i &lt; size - 1)
    {
        j = 0;
        while (j &lt; size - i - 1)
        {
            if (tab[j] &gt; tab[j + 1])
            {
                temp = tab[j];
                tab[j] = tab[j + 1];
                tab[j + 1] = temp;
            }
            j++;
        }
        i++;
    }
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">void    ft_sort_int_tab(int *tab, int size)
{
    int i;
    int temp;

    i = 0;
    while (i &lt; size - 1)
    {
        if (tab[i] &gt; tab[i + 1])
        {
            temp = tab[i];
            tab[i] = tab[i + 1];
            tab[i + 1] = temp;
            i = -1;
        }
        i++;
        
    }
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">void    ft_sort_int_tab(int *tab, int size)
{
    int    temp;
    int i;
    int j;

    i = 0;
    while (i &lt; size - 1)
    {
        j = i;
        while (j &lt; size)
        {
            if (tab[i] &gt; tab[j])
            {
                temp = tab[i];
                tab[i] = tab[j];
                tab[j] = temp;
            }
            j++;
        }
        i++;
    }
}
</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/22/c9/22c96498-055c-4f6c-9e2d-7be9349feddb.png" width="936" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/83/f2/83f24546-9ed7-4ae1-abf9-64c9f9b16f6c.png" width="974" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/5b/b9/5bb912d5-e552-4fef-98bd-878c902492d3.png" width="1029" />
  </figure>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/Wi-zMI77GHF</guid><link>https://teletype.in/@udarcs/Wi-zMI77GHF?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/Wi-zMI77GHF?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>Piscine C 00</title><pubDate>Sun, 13 Jun 2021 12:50:25 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/e4/1d/e41d9a21-ab41-4881-aa14-ca02187991b5.png"></media:content><description><![CDATA[<img src="https://teletype.in/files/f9/6b/f96b1401-236a-4d84-a5a5-70c9072ee9e3.png"></img>Piscine C 00 ex00 (ft_putchar)]]></description><content:encoded><![CDATA[
  <p>Piscine C 00 <strong>ex00 </strong>(ft_putchar)</p>
  <p>Задание:</p>
  <p>• Write a function that displays the character passed as a parameter. </p>
  <p>• It will be prototyped as follows : <code>void ft_putchar(char c);</code> </p>
  <p>• To display the character, you must use the texttt write function as follows. <code>write(1, &amp;c, 1);</code></p>
  <p>• Напишите функцию, которая отображает символ, переданный в качестве параметра. </p>
  <p>• Функция должна быть объявлена следующим образом: <code>void ft_putchar(char c);</code> </p>
  <p>• Чтобы отобразить символ, вы должны использовать в ней функцию записи текста в стандартный поток вывода, вот так: <code>write(1, &amp;c, 1);</code> Скомпилируй файл тест. В нем можно увидеть как работает эта функция вживую.</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void ft_putchar(char c)
{
  write(1, &amp;c, 1);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/f9/6b/f96b1401-236a-4d84-a5a5-70c9072ee9e3.png" width="1088" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/37/42/3742d7fa-e618-4ae0-b9d4-5f4a441a76be.png" width="802" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/1d/d8/1dd843af-a1e2-4d16-b7ee-495fac47b184.png" width="1184" />
  </figure>
  <p>Piscine C 00 <strong>ex01 </strong>(ft_print_alphabet)</p>
  <p>Задание:</p>
  <p>• Create a function that displays the alphabet in lowercase, on a single line, by ascending order, starting from the letter ’a’. • Here’s how it should be prototyped : <code>void ft_print_alphabet(void);</code></p>
  <p>• Создайте функцию, которая отображает алфавит в нижнем регистре, на одной строке, в порядке возрастания, начиная с символа «а». • Функция должна быть объявлена следующим образом: <code>void ft_print_alphabet(void);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_alphabet(void)
{
    char    letter;

    letter = &#x27;a&#x27;;
    while (letter &lt;= &#x27;z&#x27;)
    {
        ft_putchar(letter);
        letter++;
    }
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_alphabet(void)
{
    int        i;
    char    c;

    i = 97;
    while (i &lt;= 122)
    {
        c = i;
        ft_putchar(c);
        i++;
    }
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/cc/a1/cca17418-43f8-4159-a0ee-b7c06bcc2e18.png" width="817" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/56/73/5673f7e3-c314-4e12-997d-34105d41a70f.png" width="1137" />
  </figure>
  <p>Piscine C 00 <strong>ex02 </strong>(ft_print_reverse_alphabet)</p>
  <p>Задание:</p>
  <p>• Create a function that displays the alphabet in lowercase, on a single line, by descending order, starting from the letter ’z’. • Here’s how it should be prototyped : <code>void ft_print_reverse_alphabet(void);</code></p>
  <p>• Создайте функцию, которая отображает алфавит в нижнем регистре на одной строке в порядке убывания, начиная с символа «z». • Функция должна быть объявлена следующим образом: <code>void ft_print_reverse_alphabet(void);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_reverse_alphabet(void)
{
    char    letter;

    letter = &#x27;z&#x27;;
    while (letter &gt;= &#x27;a&#x27;)
    {
        ft_putchar(letter);
        letter--;
    }
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_reverse_alphabet(void)
{
    int        i;
    char    c;

    i = 122;
    while (i &gt;= 97)
    {
        c = i;
        ft_putchar(c);
        i--;
    }
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/52/32/52328fbc-7168-4cc7-9675-998d4f34bd42.png" width="812" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/dc/56/dc565014-a20e-4aa7-96a0-a108cb87edcf.png" width="914" />
  </figure>
  <p>Piscine C 00 <strong>ex03 </strong>(ft_print_numbers)</p>
  <p>Задание:</p>
  <p>• Create a function that displays all digits, on a single line, by ascending order. • Here’s how it should be prototyped : <code>void ft_print_numbers(void);</code></p>
  <p>• Создайте функцию, которая отображает все цифры на одной строке в порядке возрастания. • Функция должна быть объявлена следующим образом: <code>void ft_print_numbers(void);</code></p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_numbers(void)
{
    char    number;

    number = &#x27;0&#x27;;
    while (number &lt;= &#x27;9&#x27;)
    {
        ft_putchar(number);
        number++;
    }
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/2f/dc/2fdc4808-819c-4f91-a6fa-334baa6be5d1.png" width="1031" />
  </figure>
  <p>Piscine C 00 <strong>ex04 </strong>(ft_is_negative)</p>
  <p>Задание:</p>
  <p>• Create a function that displays ’N’ or ’P’ depending on the integer’s sign entered as a parameter. If n is negative, display ’N’. If n is positive or null, display ’P’. • Here’s how it should be prototyped : <code>void ft_is_negative(int n);</code></p>
  <p>• Создайте функцию, которая отображает символы «N» или «P» в зависимости от целочисленного знака, введенного в качестве параметра. Если n отрицательно, выведите символ «N». Если &#x27;n&#x27; является положительным или нулевым, выведите символ «P». •  Функция должна быть объявлена следующим образом: <code>void ft_is_negative(int n);</code></p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_is_negative(int n)
{
    if (n &lt; 0)
         ft_putchar(&#x27;N&#x27;);
    else
         ft_putchar(&#x27;P&#x27;);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/2e/c6/2ec67f7a-9be0-4a71-8a38-bd75cebbdacb.png" width="953" />
  </figure>
  <p>Piscine C 00 <strong>ex05 </strong>(ft_print_comb)</p>
  <p>Задание:</p>
  <p>• Create a function that displays all different combinations of three different digits in ascending order, listed by ascending order - yes, repetition is voluntary. • Here’s the intended output : </p>
  <p><code>$&gt;./a.out | cat -e </code></p>
  <p><code>012, 013, 014, 015, 016, 017, 018, 019, 023, ..., 789$&gt;</code></p>
  <p>• 987 isn’t there because 789 already is. • 999 isn’t there because the digit 9 is present more than once. • Here’s how it should be prototyped</p>
  <p><code>void ft_print_comb(void);</code></p>
  <p>• Создайте функцию, которая отображает все различные комбинации трех разных цифр в порядке возрастания, перечисленных в порядке возрастания  - да,повторение является добровольным. • Вот предполагаемый результат:</p>
  <p><code>$&gt;./a.out | cat -e </code></p>
  <p><code>012, 013, 014, 015, 016, 017, 018, 019, 023, ..., 789$&gt;</code></p>
  <p>• 987 не должно быть, потому что 789 уже есть. • 999 тоже, потому что цифра 9 присутствует более одного раза. • Функция должна быть объявлена следующим образом: <code>void ft_print_comb(void);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_commas(void)
{
    ft_putchar(&#x27;,&#x27;);
    ft_putchar(&#x27; &#x27;);
}

void    ft_print_comb(void)
{
    int num[3];

    num[0] = &#x27;0&#x27;;
    while (num[0] &lt;= &#x27;9&#x27;)
    {
        num[1] = &#x27;0&#x27;;
        while (num[1] &lt;= &#x27;9&#x27;)
        {
            num[2] = &#x27;0&#x27;;
            while (num[2] &lt;= &#x27;9&#x27;)
            {
                if (num[0] &lt; num[1] &amp;&amp; num[1] &lt; num[2])
                {
                    ft_putchar(num[0]);
                    ft_putchar(num[1]);
                    ft_putchar(num[2]);
                    if(!(num[0] == &#x27;7&#x27; &amp;&amp; num[1] == &#x27;8&#x27; &amp;&amp; num[2] == &#x27;9&#x27;))
                        ft_commas();
                }
                num[2]++;
            }
            num[1]++;
        }
        num[0]++;
    }
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ad_print_numbers(char c, char d, char u)
{
    ft_putchar(c);
    ft_putchar(d);
    ft_putchar(u);
}

void    ad_print_space(void)
{
    ft_putchar(&#x27;,&#x27;);
    ft_putchar(&#x27; &#x27;);
}

void    ft_print_comb(void)
{
    char c;
    char d;
    char u;

    c = &#x27;0&#x27;;
    while (c &lt;= &#x27;9&#x27;)
    {
        d = c + 1;
        while (d &lt;= &#x27;9&#x27;)
        {
            u = d + 1;
            while (u &lt;= &#x27;9&#x27;)
            {
                ad_print_numbers(c, d, u);
                if (!(c == &#x27;7&#x27; &amp;&amp; d == &#x27;8&#x27; &amp;&amp; u == &#x27;9&#x27;))
                {
                    ad_print_space();
                }
                u++;
            }
            d++;
        }
        c++;
    }
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_comb(void)
{
    char    nbr1;
    char    nbr2;
    char    nbr3;

    nbr1 = &#x27;0&#x27; - 1;
    while (++nbr1 &lt;= &#x27;9&#x27;)
    {
        nbr2 = nbr1;
        while (++nbr2 &lt;= &#x27;9&#x27;)
        {
            nbr3 = nbr2;
            while (++nbr3 &lt;= &#x27;9&#x27;)
            {
                if (nbr1 != &#x27;0&#x27; || nbr2 != &#x27;1&#x27; || nbr3 != &#x27;2&#x27;)
                    ft_putchar(&#x27;,&#x27;);
                if (nbr1 != &#x27;0&#x27; || nbr2 != &#x27;1&#x27; || nbr3 != &#x27;2&#x27;)
                    ft_putchar(&#x27; &#x27;);
                ft_putchar(nbr1);
                ft_putchar(nbr2);
                ft_putchar(nbr3);
            }
        }
    }
}</pre>
  <p>Решение 4</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_comb(void)
{
    int    numbers[3] = {&#x27;0&#x27;, &#x27;0&#x27;, &#x27;0&#x27;};

    while (numbers[0] &lt;= &#x27;9&#x27;)
    {
        if ((numbers[0] &lt; numbers[1]) &amp;&amp; (numbers[1] &lt; numbers[2]))
        {
            ft_putchar(numbers[0]);
            ft_putchar(numbers[1]);
            ft_putchar(numbers[2]);
            if (numbers[0] != &#x27;7&#x27;)
                ft_putchar(&#x27;,&#x27;);
            if (numbers[0] != &#x27;7&#x27;)
                ft_putchar(&#x27; &#x27;);
        }
        if (numbers[2]++ &gt;= &#x27;9&#x27;)
        {
            numbers[2] = &#x27;0&#x27;;
            numbers[1]++;
        }
        if (numbers[1] == &#x27;:&#x27;)
        {
            numbers[1] = &#x27;0&#x27;;
            numbers[0]++;
        }
    }
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/d5/40/d540c01a-fced-4a90-a3e1-a0277f2aa81b.png" width="1027" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/8c/53/8c53092e-2ba1-43f8-b89d-cdd8d8627505.png" width="734" />
  </figure>
  <p>Piscine C 00 <strong>ex06</strong> (ft_print_comb2)</p>
  <p>Задание:</p>
  <p>• Create a function that displays all different combination of two digits between 00 and 99, listed by ascending order. • Here’s the expected output :</p>
  <p><code>$&gt;./a.out | cat -e </code></p>
  <p><code>00 01, 00 02, 00 03, 00 04, 00 05, ..., 00 99, 01 02, ..., 97 99, 98 99$&gt;</code></p>
  <p>• Here’s how it should be prototyped :</p>
  <p><code>void ft_print_comb2(void);</code></p>
  <p>• Создайте функцию, которая отображает все различные комбинации двух цифр от 00 до 99, перечисленные в порядке возрастания. • Пример вывода:</p>
  <p><code>$&gt;./a.out | cat -e </code></p>
  <p><code>00 01, 00 02, 00 03, 00 04, 00 05, ..., 00 99, 01 02, ..., 97 99, 98 99$&gt;</code></p>
  <p>• Скомпилируй файл тест. В нем можно увидеть как работает эта функция вживую</p>
  <p><code>void ft_print_comb2(void);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_comb2(void)
{
    int        i;
    int        k;

    i = 0;
    k = 0;
    while (i &lt; 100)
    {
        k = i + 1;
        while (k &lt; 100)
        {
            ft_putchar(i / 10 + &#x27;0&#x27;);
            ft_putchar(i % 10 + &#x27;0&#x27;);
            ft_putchar(&#x27; &#x27;);
            ft_putchar(k / 10 + &#x27;0&#x27;);
            ft_putchar(k % 10 + &#x27;0&#x27;);
            if ((i / 10 != 9) || (i % 10 != 8))
            {
                ft_putchar(&#x27;,&#x27;);
                ft_putchar(&#x27; &#x27;);
            }
            k++;
        }
        i++;
    }
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_print_comb2(void)
{
    int        i;
    int        k;

    i = 0;
    k = 0;
    while (i &lt; 100)
    {
        k = i + 1;
        while (k &lt; 100)
        {
            ft_putchar(i / 10 + &#x27;0&#x27;);
            ft_putchar(i % 10 + &#x27;0&#x27;);
            ft_putchar(&#x27; &#x27;);
            ft_putchar(k / 10 + &#x27;0&#x27;);
            ft_putchar(k % 10 + &#x27;0&#x27;);
            if ((i / 10 != 9) || (i % 10 != 8))
            {
                ft_putchar(&#x27;,&#x27;);
                ft_putchar(&#x27; &#x27;);
            }
            k++;
        }
        i++;
    }
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void        ft_putchar(char c)
{
    write(1, &amp;c, 1);
}


void    ft_makechars(int i)
{
    ft_putchar(i / 10 + 48);
    ft_putchar(i % 10 + 48);
}

void    ft_putthem(int x, int y)
{
    if (x &lt; 10)
    {
        ft_putchar(48);
        ft_putchar(x + 48);
    }
    else
        ft_makechars(x);
    ft_putchar(&#x27; &#x27;);
    if (y &lt; 10)
    {
        ft_putchar(48);
        ft_putchar(y + 48);
    }
    else
        ft_makechars(y);
    if (!(x + y == 197))
    {
        ft_putchar(&#x27;,&#x27;);
        ft_putchar(&#x27; &#x27;);
    }
}

void    ft_print(int x, int y)
{
    if (x &lt; y)
    {
        ft_putthem(x, y);
    }
}

void    ft_calc_numbers(int x[])
{
    while (x[0] &lt; 100)
    {
        x[1] = 0;
        while (x[1] &lt; 100)
        {
            ft_print(x[0], x[1]);
            x[1]++;
        }
        x[0]++;
    }
}

void    ft_print_comb2(void)
{
    int x[2];

    x[0] = 0;
    x[1] = 1;
    ft_calc_numbers(x);
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/b2/32/b232c999-b3ab-46df-a3ff-8ec5a3e24dd1.png" width="797" />
  </figure>
  <p>Piscine C 00 <strong>ex07</strong> (ft_putnbr)</p>
  <p>Задание:</p>
  <p>• Create a function that displays the number entered as a parameter. The function has to be able to display all possible values within an int type variable. • Here’s how it should be prototyped : <code>void ft_putnbr(int nb);</code></p>
  <p>• For example:  <code>ft_putnbr(42)</code> displays &quot;42&quot;</p>
  <p>• Создайте функцию, которая отображает число, введенное в качестве параметра. Функция должна иметь возможность отображать все возможные значения в переменной типа int. • Вот как это должно быть объявлено: <code>void ft_putnbr(int nb);</code></p>
  <p>• Например: <code>ft_putnbr(42)</code> displays &quot;42&quot;</p>
  <p>Решение 1</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putnbr(int nb)
{
    int    temp;
    int    size;

    size = 1;
    if (nb &lt; 0)
    {
        ft_putchar(&#x27;-&#x27;);
        nb = -nb;
    }
    if (nb == -2147483648)
    {
        ft_putchar(&#x27;2&#x27;);
        nb = 147483648;
    }
    temp = nb;
    while ((temp /= 10) &gt; 0)
        size *= 10;
    temp = nb;
    while (size)
    {
        ft_putchar((char)((temp / size)) + 48);
        temp %= size;
        size /= 10;
    }
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putnbr(int nb)
{
    char    c;

    if (nb &lt; 0)
    {
        nb = -nb;
        ft_putchar(&#x27;-&#x27;);
    }
    if (nb &lt; 10)
        ft_putchar(nb + &#x27;0&#x27;);
    else
    {
        ft_putnbr(nb / 10);
        ft_putnbr(nb % 10);
    }
}</pre>
  <p>Решение 3</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_putnbr(int nb)
{
    if (nb &gt;= 10)
    {
        ft_putnbr(nb / 10);
        ft_putnbr(nb % 10);
    }
    else
    {
        ft_putchar(nb + &#x27;0&#x27;);
    }
}
</pre>
  <p>Решение 4</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_printnbr(int x[])
{
    int i;
    int b;

    i = 0;
    b = 0;
    while (i &lt; 10)
    {
        if (b == 1)
        {
            ft_putchar(x[i] + 48);
        }
        else
        {
            if (x[i] &gt; 0)
            {
                b = 1;
                ft_putchar(x[i] + 48);
            }
        }
        i++;
    }
}

void    ft_preventoverflow(void)
{
    ft_putchar(&#x27;-&#x27;);
    ft_putchar(&#x27;2&#x27;);
    ft_putchar(&#x27;1&#x27;);
    ft_putchar(&#x27;4&#x27;);
    ft_putchar(&#x27;7&#x27;);
    ft_putchar(&#x27;4&#x27;);
    ft_putchar(&#x27;8&#x27;);
    ft_putchar(&#x27;3&#x27;);
    ft_putchar(&#x27;6&#x27;);
    ft_putchar(&#x27;4&#x27;);
    ft_putchar(&#x27;8&#x27;);
}

void    ft_fillarray(int x[], int nb)
{
    int t;

    t = 9;
    while (t &gt;= 0)
    {
        x[t] = nb % 10;
        nb /= 10;
        t--;
    }
}

void    ft_putnbr(int nb)
{
    int x[10];

    if (nb == 0)
        ft_putchar(&#x27;0&#x27;);
    else
    {
        if (nb == -2147483648)
            ft_preventoverflow();
        else
        {
            if (nb &lt; 0)
            {
                ft_putchar(&#x27;-&#x27;);
                nb = nb + -2 * nb;
            }
            ft_fillarray(x, nb);
            ft_printnbr(x);
        }
    }
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/84/a5/84a5846b-e942-4b49-b1e0-25ef9502356f.png" width="1083" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/8b/21/8b2163d2-5d19-4c36-a9f2-df5da68d40f1.png" width="1084" />
  </figure>
  <p>Piscine C 00 <strong>ex08</strong> (ft_putnbr)</p>
  <p>Задание:</p>
  <p>• Create a function that displays all different combinations of n numbers by ascending<br />order.<br />• n will be so that : 0 &lt; n &lt; 10.<br />• If n = 2, here’s the expected output :</p>
  <p><code>$&gt;./a.out | cat -e</code></p>
  <p><code>01, 02, 03, ..., 09, 12, ..., 79, 89$&gt;</code></p>
  <p>• Here’s how it should be prototyped : <code>void ft_print_combn(int n);</code></p>
  <p>• Создайте функцию, которая отображает все различные комбинации из &#x27;n&#x27; чисел в порядке возрастания. • n должно быть таким таким, чтоб: 0 &lt; n &lt;10 • сли n = 2, результат должен быть таким: </p>
  <p><code>$&gt;./a.out | cat -e</code></p>
  <p><code>01, 02, 03, ..., 09, 12, ..., 79, 89$&gt;</code></p>
  <p>Разрешенные функции: write</p>
  <p>• Скомпилируй файл тест : <code>void ft_print_combn(int n);</code></p>
  <p>Решение 1</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

void    ft_check_print(int x[], int n)
{
    int i;
    int yes;

    i = 0;
    yes = 1;
    while (i &lt; n - 1)
    {
        if (!(x[i] &lt; x[i + 1]))
            yes = 0;
        i++;
    }
    if (yes == 1)
    {
        i = 0;
        while (i &lt; n)
        {
            ft_putchar(x[i]);
            i++;
        }
        if (x[0] != &#x27;9&#x27; - n + 1)
        {
            ft_putchar(&#x27;,&#x27;);
            ft_putchar(&#x27; &#x27;);
        }
    }
}

void    create_while(int x[], int k, int n)
{
    if (k == n - 1)
    {
        x[k] = &#x27;0&#x27;;
        while (x[k] &lt;= &#x27;9&#x27;)
        {
            if (n == 9 &amp;&amp; x[0] &gt; &#x27;1&#x27;)
                break ;
            ft_check_print(x, n);
            x[k]++;
        }
    }
    else
    {
        x[k] = &#x27;0&#x27;;
        while (x[k] &lt;= &#x27;9&#x27;)
        {
            create_while(x, k + 1, n);
            x[k]++;
        }
    }
}

void    ft_print_combn(int n)
{
    int x[n];

    create_while(x, 0, n);
}</pre>
  <p>Решение 2</p>
  <pre data-lang="c">#include &lt;unistd.h&gt;

void    ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

static void    ft_me_cago_en_norminette(int *arr, int col, int n)
{
    int        i;

    while (col)
    {
        while (arr[col] == (9 + col - (n - 1)) &amp;&amp; col &gt;= 0)
            col -= 1;
        if (col &lt; 0)
            break ;
        arr[col] += 1;
        i = (col + 1) - 1;
        while (i++ &lt; n)
            arr[i] = arr[i - 1] + 1;
        col = n - 1;
        ft_putchar(&#x27;,&#x27;);
        ft_putchar(&#x27; &#x27;);
        i = 0;
        while (i &lt; n)
            ft_putchar(arr[i++] + &#x27;0&#x27;);
    }
}

void        ft_print_combn(int n)
{
    int        arr[n];
    int        i;
    int        col;

    col = n - 1;
    i = -1;
    if (n &lt;= 10)
    {
        while (i++ &lt; n)
            arr[i] = i;
        i = 0;
        while (i &lt; n)
            ft_putchar(arr[i++] + &#x27;0&#x27;);
        ft_me_cago_en_norminette(arr, col, n);
        ft_putchar(&#x27;\n&#x27;);
    }
}</pre>
  <p>Объяснения + проверка int main</p>
  <p>Команда для компиляции и одновременного запуска:</p>
  <p>gcc -Wall -Werror -Wextra <strong>названиефайла.c</strong> &amp;&amp; chmod +x ./a.out &amp;&amp; ./a.out</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/87/6a/876a3661-2aae-49ad-8598-f8c90c35840a.png" width="871" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/11/56/11567440-29b4-421d-b73a-f60eb23c595d.png" width="894" />
  </figure>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/KdaHbulspRP</guid><link>https://teletype.in/@udarcs/KdaHbulspRP?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/KdaHbulspRP?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>Готовится к Школе программирования 21 и школе 42 в Москве?</title><pubDate>Fri, 11 Jun 2021 17:13:05 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/8f/f3/8ff3e89b-414a-4331-aae0-18f8a75ec611.png"></media:content><category>Школа 21</category><description><![CDATA[<img src="https://teletype.in/files/18/2d/182d7853-819c-437d-8028-2a26ab99a53a.jpeg"></img>https://21-school.ru/]]></description><content:encoded><![CDATA[
  <figure class="m_original">
    <img src="https://teletype.in/files/18/2d/182d7853-819c-437d-8028-2a26ab99a53a.jpeg" width="647" />
    <figcaption>Школа программирования 21 и 42 </figcaption>
  </figure>
  <p><a href="https://21-school.ru/" target="_blank">https://21-school.ru/</a></p>
  <p>Вопросы по школе 21 <a href="https://github.com/daniiomir/faq_for_school_21" target="_blank">(читать ответы здесь)</a></p>
  <p>Если вы ничего не понимаете в программировании, скажу со 100% уверенностью, готовится нужно обязательно!</p>
  <p>Начать стоит с азов.</p>
  <p>Английский язык обязательно, иначе не поймете что от вас требуется.</p>
  <figure class="m_retina" data-caption-align="center">
    <img src="https://teletype.in/files/44/c8/44c8120f-1ac4-48ee-994c-37ea90c43c30.png" width="24" />
    <figcaption>Telegram</figcaption>
  </figure>
  <p>Группа об учебе <strong>Школа 21</strong> в телеграмме <a href="https://t.me/joinchat/9jkjtTF7RDszZTUy" target="_blank">(ссылка)</a> </p>
  <h2>Работа с командной строкой &quot;shell&quot;</h2>
  <ol>
    <li>Список заданий C Piscine Shell 00 <a href="https://teletype.in/@udarcs/PaREDM3oFqb" target="_blank">(решать)</a> <a href="https://cloud.mail.ru/public/ES2j/2TeB4SVtG" target="_blank">(смотреть)</a></li>
    <li>Список заданий C Piscine Shell 01 <a href="https://cloud.mail.ru/public/y6sv/zg3tszJAE" target="_blank">(смотреть)</a></li>
  </ol>
  <p>Изучив основные команды шелл можете переходить к языку &quot;C&quot;</p>
  <h2>Изучение программирования на С</h2>
  <figure class="m_original">
    <img src="https://teletype.in/files/4a/56/4a56f3ba-6890-4802-a1bb-b926be4f8215.jpeg" width="647" />
    <figcaption>Изучение C</figcaption>
  </figure>
  <p>Перед началом прочитайте курс: &quot;<strong>С</strong>&quot; из Бауманки. <a href="https://cloud.mail.ru/public/of6t/qkvV8mMTm" target="_blank">(здесь)</a></p>
  <p>Шикарная инструкция по Си &quot;<strong>C</strong>&quot; <a href="https://metanit.com/cpp/c/2.1.php" target="_blank">(здесь)</a></p>
  <ol>
    <li>Задание C Piscine C 00 <a href="https://teletype.in/@udarcs/Wi-zMI77GHF" target="_blank">(решать)</a> <a href="https://cloud.mail.ru/public/awWc/jonxtb3sh" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 01 <a href="https://teletype.in/@udarcs/Yz117IvnPQB" target="_blank">(решать)</a> <a href="https://cloud.mail.ru/public/3aZY/Qjmfh1JCV" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 02 <a href="https://teletype.in/@udarcs/LXj3R5xw7K1" target="_blank">(решать)</a> <a href="https://cloud.mail.ru/public/c1M1/Y6GrDeL9L" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 03 <a href="https://teletype.in/@udarcs/1Vj-ZU-8r0F" target="_blank">(решать)</a> <a href="https://cloud.mail.ru/public/ko7B/AqyjA7eN7" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 04 <a href="https://teletype.in/@udarcs/_gFB31wsly4" target="_blank">(решать)</a> <a href="https://cloud.mail.ru/public/oqYf/1MrqLiTYw" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 05 (решать) <a href="https://cloud.mail.ru/public/1fHH/eZQSa1vDj" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 06 (решать) <a href="https://cloud.mail.ru/public/jKSW/LBZRpmRrP" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 07 (решать) <a href="https://cloud.mail.ru/public/iXay/q3UhXzo4A" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 08 (решать) <a href="https://cloud.mail.ru/public/4j7u/3Eoz7SmUs" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 09 (решать) <a href="https://cloud.mail.ru/public/4hLW/t7eUAaEV3" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 10 (решать) <a href="https://cloud.mail.ru/public/yBzv/R4ndu9Kaf" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 11 (решать) <a href="https://cloud.mail.ru/public/EjK7/4TwLaoioF" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 12 (решать) <a href="https://cloud.mail.ru/public/Z2MT/EpfNrmDza" target="_blank">(смотреть)</a></li>
    <li>Задание C Piscine C 13 (решать) <a href="https://cloud.mail.ru/public/9Uhb/dhobGXQz3" target="_blank">(смотреть)</a></li>
  </ol>
  <p></p>
  <p>Смотреть на git <a href="https://github.com/evgenkarlson/COMPLETED_PISCINE_C" target="_blank">(здесь)</a></p>
  <p></p>
  <p>Порядок уроков.</p>
  <p>Rush 00, 01, 02, BSQ - Являются групповыми по желанию.</p>
  <figure class="m_column">
    <img src="https://teletype.in/files/f6/8d/f68d7070-4fbe-4e47-8c60-3938a54e4f00.jpeg" width="1161" />
    <figcaption>Школа 21 Sberbank порядок уроков.</figcaption>
  </figure>
  <p>На 1 день, дается 1 урок.</p>
  <p>Примеры решений на Git <a href="https://github.com/anononamemo/42_Piscine_Reloaded" target="_blank">https://github.com/anononamemo/42_Piscine_Reloaded</a></p>
  <p>Пишете в Google &quot;git ft_putchar&quot; изучаете как можно решать задачи.</p>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/HgDVhvqz-D1</guid><link>https://teletype.in/@udarcs/HgDVhvqz-D1?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/HgDVhvqz-D1?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>Школа 42 в Москве</title><pubDate>Mon, 07 Jun 2021 21:33:19 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/cd/88/cd8823db-53fd-4974-a39e-7dfa0e3870df.png"></media:content><category>Школа 21</category><description><![CDATA[<img src="https://teletype.in/files/36/b4/36b43dcc-d261-4ded-bc72-1439b3090677.png"></img>Основные команды:]]></description><content:encoded><![CDATA[
  <figure class="m_original">
    <img src="https://teletype.in/files/36/b4/36b43dcc-d261-4ded-bc72-1439b3090677.png" width="1055" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/18/2d/182d7853-819c-437d-8028-2a26ab99a53a.jpeg" width="647" />
    <figcaption>shcool 21 и shcool 42</figcaption>
  </figure>
  <p>Основные команды:</p>
  <p>Школа 21</p>
  <p>Shell - Командная строка</p>
  <p>cd - перейти в директорию</p>
  <p>cd .. - на одну папку выше</p>
  <p>mkdir - создать директорию</p>
  <p>rm -r - удалить директорию</p>
  <p>ls -l - права и файлы в директории</p>
  <p>cat </p>
  <p>touch - создать</p>
  <p>vim - редактор :w - save :q - quit</p>
  <p>ln - hard link</p>
  <p>ln -s  sim link</p>
  <p>chmod - назначить права</p>
  <p><br /></p>
  <p>И запомните святые заклинания</p>
  <p></p>
  <ol>
    <li><strong>git init -</strong> инициализация гита c</li>
    <li><strong>git add *</strong> - все в гит</li>
    <li><strong>git commit</strong> -  комит на все загруженное</li>
    <li><strong>git push</strong> - загружаем </li>
  </ol>
  <p><strong>git log</strong></p>
  <p><strong>git diff</strong></p>
  <p><strong>git log --name-status</strong> проверить что загруженно </p>
  <p><strong>git add -a</strong>  добавления всех файлов в комит commit</p>
  <p><strong>git commit -m</strong> &quot;пишем название комета&quot;</p>
  <p><strong>git push origin master</strong>  пушим коммит ( загружаем в гит)</p>
  <p><strong>git clean</strong> имя файла (удаляем из гита файл)</p>
  <p><strong>git clean -f -x</strong> удаляем все что красное</p>
  <p></p>
  <h2>Задания</h2>
  <p>Читать здесь <a href="https://teletype.in/@udarcs/KdaHbulspRP" target="_blank">(читать)</a></p>
  <p></p>
  <h2><br />C Piscine C 00</h2>
  <p>Все решения после компиляции gcc проверяем через norminette</p>
  <p> <a href="https://21-school.ru/norminette" target="_blank">https://21-school.ru/norminette</a></p>
  <p>C Piscine C 00 <strong>ex00</strong></p>
  <p>ft_putchar.c</p>
  <pre data-lang="c">#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;

void ft_putchar(char c)
{
    write(1, &amp;c, 1);
}

int main(void)
{
    char c = &#x27;c&#x27;;
    ft_putchar(c);
}</pre>
  <p>Более правильное решение. ( Для проверки удаляем int main )</p>
  <pre data-lang="c">void ft_putchar(char c)
{
  write(1, &amp;c, 1);
}</pre>
  <p></p>
  <p>C Piscine C 00 <strong>ex01</strong></p>
  <p>ft_print_alphabet.c</p>
  <pre data-lang="c">#include &lt;stdio.h&gt;

void ft_print_alphabet(void)
{
    char letter;

    letter = &#x27;a&#x27;;
    while (letter &lt;= &#x27;z&#x27;)
    {
        putchar(letter);
        letter++;
    }
}

int main(void)
{
    ft_print_alphabet();
    return 0;
}  </pre>
  <p>Верное решение убирает % в конце строки.  ft_putchar(&#x27;\n&#x27;); </p>
  <pre data-lang="c">void ft_print_alphabet(void)
{
  int letter = &#x27;a&#x27;;
  while (letter &gt;= &#x27;a&#x27; &amp;&amp; letter &lt;= &#x27;z&#x27;)
    ft_putchar(letter++);
  ft_putchar(&#x27;\n&#x27;);
}</pre>
  <p></p>
  <p>C Piscine C 00 <strong>ex02</strong></p>
  <p>ft_print_reverse_alphabet.c</p>
  <pre data-lang="c">#include &lt;stdio.h&gt;

void    ft_print_reverse_alphabet(void)
{
    char    letter;

    letter = &#x27;z&#x27;;
    while (letter &gt;= &#x27;a&#x27;)
    {
        putchar(letter);
        letter--;
    }
}

int main(void)
{
    ft_print_reverse_alphabet();
    return (0);
}</pre>
  <p></p>
  <p>C Piscine C 00 <strong>ex03</strong></p>
  <p>ft_print_numbers.c</p>
  <pre data-lang="c">#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;

void	ft_putchar(char c)
{
	write(1, &amp;c, 1);
}

void	ft_print_numbers(void)
{
	char	number;

	number = &#x27;0&#x27;;
	while (number &lt;= &#x27;9&#x27;)
	{
		ft_putchar(number);
		number++;
	}
	ft_putchar(&#x27;\n&#x27;);
}

int	main(void)
{
	ft_print_numbers();
}</pre>
  <p>Исправили на короткое и более правильное решение.</p>
  <pre data-lang="c">void	ft_print_numbers(void)
{
  int i = &#x27;48&#x27;;
  while (i &gt;=&#x27;47&#x27; &amp;&amp; i &lt;= &#x27;57&#x27;)
    ft_putchar(i++);
  ft_putchar(&#x27;\n&#x27;);
}</pre>
  <p></p>
  <p>C Piscine C 00 <strong>ex04</strong></p>
  <p>ft_is_negative.c</p>
  <pre data-lang="c">void	ft_putchar(char c)
{
	write(1, &amp;c, 1);
}

void	ft_is_negative(int n)
{
	if (n &gt;= 0)
	{
		ft_putchar(&#x27;P&#x27;);
	}
	else
	{
		ft_putchar(&#x27;N&#x27;);
	}
}
int main(void)
{                                                        18,0-1         Bot</pre>
  <h2>C Piscine C 01</h2>
  <p>C Piscine C 01 <strong>ex00</strong></p>
  <p>- Создайте функцию, которая принимает указатель на &#x27;int&#x27; в качестве параметра и задает значение &quot;42&quot; для этого &#x27;int&#x27;. </p>
  <p>- Вот как это должно быть объявлено:</p>
  <pre data-lang="c">void ft_ft(int *nbr)
{
    *nbr = 42;
}</pre>
  <figure class="m_original">
    <img src="https://teletype.in/files/33/1e/331eff36-6e96-4c59-a9c4-6a532435a6af.png" width="1125" />
  </figure>
  <p>C Piscine C 01 <strong>ex01</strong></p>
  <p>Создайте функцию, которая принимает &quot;указатель на указатель на указатель на<br />указатель на указатель на указатель на указатель на указатель на указатель на<br />указатель на указатель&quot; на &#x27;int&#x27; в качестве параметра и устанавливает значение<br />&quot; 42 &quot; для этого &#x27;int&#x27;.</p>
  <p>- Вот как это должно быть обьявлено:<br />void	ft_ultimate_ft(int *********nbr);</p>
  <pre data-lang="c">void    ft_ultimate_ft(int *********nbr)
{
    *********nbr = 42;
}</pre>
  <figure class="m_original">
    <img src="https://teletype.in/files/57/8d/578d7169-33db-425d-9021-5dd455753045.png" width="1169" />
  </figure>
  <p>C Piscine C 01 <strong>ex02</strong></p>
  <p>Создайте функцию, которая меняет местами значения двух целых чисел, адреса<br />которых вводятся в качестве параметров.</p>
  <p>- Вот как это должно быть объявлено:</p>
  <p>void	ft_swap(int *a, int *b);</p>
  <pre data-lang="c">void    ft_swap(int *a, int *b)
{
    int    temp;

    temp = *a;
    *a = *b;
    *b = temp;
}</pre>
  <p>или</p>
  <pre data-lang="c">void        ft_swap(int *a, int *b)
{
    int t;

    t = *a;
    *a = *b;
    *b = t;
}</pre>
  <figure class="m_original">
    <img src="https://teletype.in/files/69/4d/694d1087-b379-4869-92cf-f88212ab217a.png" width="1167" />
  </figure>
  <p>C Piscine C 01 <strong>ex03</strong></p>
  <p></p>
  <h2>C Piscine C 02</h2>
  <p>C Piscine C 02 <strong>ex00</strong></p>
  <p>char *ft_strcpy(char *dest, char *src);</p>
  <pre data-lang="c">#include    &lt;stdio.h&gt;

char    *ft_strcpy(char *dest, char *src)
{
    int i;

    i = 0;
    while (src[i] != &#x27;\0&#x27;)
    {
        dest[i] = src[i];
        i ++;
    }
    dest[i] = src[i];
    return (dest);
}        </pre>
  <figure class="m_column">
    <img src="https://teletype.in/files/8b/03/8b0319f6-bd6b-422f-8433-07591e978653.png" width="1002" />
  </figure>
  <p>C Piscine C 02 <strong>ex01</strong></p>
  <p>char    *ft_strncpy(char *dest, char *src, unsigned int n)</p>
  <pre data-lang="c">#include &lt;stdio.h&gt;

char    *ft_strncpy(char *dest, char *src, unsigned int n)
{
    unsigned int    i;

    i = 0;
    while (src[i] != &#x27;\0&#x27; &amp;&amp; i &lt; n)
    {
        dest[i] = src[i];
        ++i;
    }
    while (i &lt; n)
    {
        dest[i] = &#x27;\0&#x27;;
        i++;
    }
    return (dest);
}</pre>
  <figure class="m_column">
    <img src="https://teletype.in/files/85/60/85605aec-c395-45be-bfc6-3eb6cdf28156.png" width="998" />
  </figure>
  <p>C Piscine C 02 <strong>ex02</strong></p>
  <p>int ft_str_is_alpha(char *str);</p>
  <pre data-lang="c">
#include &lt;stdio.h&gt;

int ft_str_is_alpha(char *str)
{
    int i;

    i = 0;
    while (str[i] != &#x27;\0&#x27;)
    {
        if ((str[i] &lt; &#x27;A&#x27; || str[i] &gt; &#x27;Z&#x27;) &amp;&amp; (str[i] &lt; &#x27;a&#x27; || str[i] &gt; &#x27;z&#x27;))
        {
            return (0);
            break ;
        }
        i++;
    }
    return (1);
}
                                                   </pre>
  <figure class="m_column">
    <img src="https://teletype.in/files/1e/04/1e04a263-47af-4797-91eb-1b6afa6dcb98.png" width="1402" />
  </figure>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/06NhfbJR6P3</guid><link>https://teletype.in/@udarcs/06NhfbJR6P3?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/06NhfbJR6P3?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>Swift Class</title><pubDate>Mon, 17 May 2021 15:29:49 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/68/eb/68ebbaaa-4226-43e8-a8f4-330c59e806e2.png"></media:content><description><![CDATA[<img src="https://teletype.in/files/11/df/11df9e90-c5e4-4573-968e-e61073c5b7b4.png"></img>]]></description><content:encoded><![CDATA[
  <figure class="m_original">
    <img src="https://teletype.in/files/11/df/11df9e90-c5e4-4573-968e-e61073c5b7b4.png" width="940" />
  </figure>
  <pre data-lang="swift">class Player {
    
    let name: String
    let game: String
    let age: Int
    
    var playerInfo: String {
        let playerInfo = &quot;&quot;&quot;
        Player name is \(name).
        He plays \(game).
        He is \(age) years old.
        &quot;&quot;&quot;
        return playerInfo
    }
    
    init(name: String, game: String, age: Int) {
        self.name = name
        self.game = game
        self.age = age
    }
}


let player = Player(name: &quot;Mikhail&quot;, game: &quot;Football&quot;, age: 22)
print(player.playerInfo)</pre>

]]></content:encoded></item><item><guid isPermaLink="true">https://teletype.in/@udarcs/MGOFnnoJCWw</guid><link>https://teletype.in/@udarcs/MGOFnnoJCWw?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs</link><comments>https://teletype.in/@udarcs/MGOFnnoJCWw?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=udarcs#comments</comments><dc:creator>udarcs</dc:creator><title>Swift 2021 бесплатные уроки для новичка. Часть 1</title><pubDate>Tue, 11 May 2021 21:03:42 GMT</pubDate><media:content medium="image" url="https://teletype.in/files/d4/3d/d43df9c5-8b7e-4086-958d-645f07884454.png"></media:content><description><![CDATA[<img src="https://ic.pics.livejournal.com/udarcs/88244882/394/394_original.png"></img>Часть 1 (1-10 уроки)]]></description><content:encoded><![CDATA[
  <p>Часть 1 (1-10 уроки)</p>
  <p><a href="https://teletype.in/@udarcs/TyDy3dzCr01" target="_blank">Часть 2 (11-20 уроки)</a></p>
  <p><a href="https://teletype.in/@udarcs/Eh0oI7zDWoA" target="_blank">Часть 3 (15-20 уроки)</a></p>
  <p>// За кавычками находятся комментарий. (Не код.)</p>
  <p>// Шикарный видео курс для новичка от <a href="https://www.instagram.com/ian_solomein/" target="_blank"><strong>Яна Соломеина</strong></a></p>
  <p>В этом видео 2020 года рассказываются самые основы. Ниже изложен код и его результат. Вы можете копировать себе код и на его основе собирать свои конструкции. Для начала это идеальный урок.</p>
  <figure class="m_custom">
    <iframe src="https://l.lj-toys.com/?auth_token=sessionless%3A1620763200%3Aembedcontent%3A88244882%2615%26%26%26youtube%26ZJcVUSfdVyo%3Aa392951f306d8d5b845a747a98261e7c654e50cb&source=youtube&vid=ZJcVUSfdVyo&moduleid=15&preview=&journalid=88244882&noads="></iframe>
  </figure>
  <h2>// <strong>Lesson 1</strong> // Constant / Константы</h2>
  <p>// Видео <a href="https://www.youtube.com/watch?v=ZJcVUSfdVyo&t=263s" target="_blank">4:23</a>​ Константы и переменные</p>
  <pre data-lang="swift">let — константа (неизменная)
var — переменная (от слова «variable» — переменная )
let greetings = &quot;Hello, World&quot; 
var direction = &quot;Left&quot; 
direction = &quot;Right&quot;
greetings</pre>
  <p>// direction - направление</p>
  <p>// greetings - приветствие<br />// let константа может быть одна и не меняется</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/394/394_original.png" width="579" />
    <figcaption>Как выглядит код в Xcode 12.5</figcaption>
  </figure>
  <h2>// <strong>Lesson 2</strong> // Type data / Тип данных</h2>
  <p>// Видео <a href="https://www.youtube.com/watch?v=ZJcVUSfdVyo&t=795s" target="_blank">13:15</a>​ Типы данных</p>
  <p><strong>Int</strong> — integral (целочисленное, целое число) 1, 12, -4, 99, складываются между собой.</p>
  <p><strong>Float</strong> — Число с плавающей точкой (2.134) Floating-point number (2.1234567 7 цифр после запятой не точные вычисления) отличие в точности.</p>
  <p><strong>Double</strong> — Число с плавающей точкой (2.134) double-precision floating-point number (2.342342344 64x самые точные вычисления, выбирается по умолчанию)</p>
  <pre data-lang="swift">var a = 42
var b = -27
var x = 5.47
var c = -300.145</pre>
  <p>//var <strong>sum </strong>(суммирование)</p>
  <p>var sum = <strong>Double</strong>(<strong>a</strong>) + <strong>x</strong>  // Складываем Int (a)+ Double(x) для точного сложения преобразовываем целочисленное Integral в Double в таком случае все что находится после точке учитывается в уравнении 42+5.47=47.47 если преобразуем var sum = <strong>a</strong> + <strong>Int</strong>(<strong>x</strong>) получим 42+5.47=47 все что после точки съело.</p>
  <pre data-lang="swift">var hiBro = &quot;Hello, word&quot;
var h = &quot;Hello, &quot;
var r = &quot;people!&quot;
var sum2 = h + r
print(&quot;Hi \(r)&quot;) </pre>
  <p>// Складываем строки методом Конкатенации <strong>\()</strong></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/a7/e4/a7e429ec-8ae7-4080-8f0f-a8d1e4c49746.png" width="626" />
  </figure>
  <h2>// <strong>Lesson 3</strong> // Boolean (Логические) / Bool</h2>
  <p>// Булевы значения (<strong>True</strong> — Верно) (<strong>False</strong> — лож, нет, не верно.)</p>
  <p></p>
  <p>// <strong>!а </strong>— Не</p>
  <p></p>
  <p>// <strong>a &amp;&amp; b </strong>— И</p>
  <p></p>
  <p>// <strong>a || b </strong>— или</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/02/b5/02b50fb6-e48d-4c95-8c5e-e1ba72e74db9.png" width="963" />
  </figure>
  <pre data-lang="swift">var areYouHappy = true  </pre>
  <p>// Дана переменная <strong>areYouHappy</strong></p>
  <p><strong>// Пример 1</strong></p>
  <pre data-lang="swift">if areYouHappy { 
print(&quot;Good&quot;) 
} else { 
print(&quot;Bad&quot;)
}</pre>
  <p>// <strong>if</strong> — если</p>
  <p>// <strong>true </strong>— если (areYouHappy = <strong>true ) </strong>выводить это</p>
  <p>// <strong>else</strong> — ещё</p>
  <pre data-lang="swift">var areYouHappy2 = false </pre>
  <p>// Дана переменная <strong>areYouHappy2</strong></p>
  <p><strong>// Пример 2</strong></p>
  <pre data-lang="swift">if areYouHappy2 {
print(&quot;Good&quot;)
} else {
print(&quot;Bad&quot;) 
}</pre>
  <p>// <strong>false </strong>— если (areYouHappy2<strong> = false) </strong>выводить это</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/84/89/8489f132-bc2f-491f-83a3-5296e7bcd755.png" width="582" />
  </figure>
  <figure class="m_original">
    <img src="https://teletype.in/files/4b/42/4b423ffd-64f6-40d9-84db-ce8a241497ea.png" width="902" />
  </figure>
  <h2>// Lesson 4 // Сложение чисел Int + Double</h2>
  <p><strong>// Int</strong> — Целочисленное 1, 5, 7, -10,</p>
  <p><strong>// Double</strong> — Число с плавающей точкой 3.23, 7.12467 , -0.2444</p>
  <pre>var a = 42.25                  // a — является Double Дабл (по умолчанию)</pre>
  <pre>var b = 10                     // b — является Int Интеграл</pre>
  <pre>var sum2 = Int(a) + b          // Число (a) 42.25 превращаем в Int</pre>
  <p>// Неверный способ. Ответ будет 42.25+10 = 52 все что после точки пропадает.</p>
  <pre>var sum3 = a + Double(b)       // Необходимо Int(b) 10 превратить в Double</pre>
  <p>// Верный способ. Ответ будет 42.25+10 = 52.25</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/9b/ec/9becd7e5-4b70-4724-8c77-9d1886081c7e.png" width="650" />
  </figure>
  <h2>// Lesson 5 // Basic Operators</h2>
  <p>// Видео <a href="https://www.youtube.com/watch?v=ZJcVUSfdVyo&t=1877s" target="_blank">31:17</a>​ Базовые операторы</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/03/38/03387089-e438-4885-987f-0d08163a737b.png" width="697" />
    <figcaption>операторы</figcaption>
  </figure>
  <p></p>
  <p><strong>// Унарные</strong></p>
  <p><strong>Префиксные:</strong> (перед выражением) <strong>-</strong>а <strong>!</strong>b <strong>+</strong>c</p>
  <p><strong>Постфиксные:</strong> (после выражения) x<strong>+ </strong>u<strong>-</strong></p>
  <p><strong>// Бинарные </strong></p>
  <p>// <strong>Инфиксные:</strong> (ин внутри in) 1 + 2</p>
  <p>// 1, 2 — это операнды — данные которые обрабатываются с помощью +-:*%</p>
  <p><strong>// Тернарные</strong></p>
  <p>a <strong>?</strong> b <strong>:</strong> c ( если <strong>а</strong> (true = <strong>?</strong>) то что верно <strong>b</strong> или <strong>с</strong> )</p>
  <p><strong>// Оператор присваивания</strong></p>
  <p>= ( let <strong>a</strong> = 5 присваиваем константе <strong>а</strong> цифру 5 ) var <strong>a</strong> = 5</p>
  <p><strong>// Арифметические операторы</strong></p>
  <pre data-lang="swift">+, -, *, /, %
let x = 12
let y = 5

x + y
x - y
x * y
x / y

let h = &quot;Hello, &quot;                  //Строки можем складывать
let g = &quot;Swift.&quot;

h + g</pre>
  <p>// Ответ: Hello, Swift.</p>
  <pre data-lang="swift">x % y</pre>
  <p>// 12/ делим (5 * 2) + 2</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/f4/6a/f46ae3dd-8e43-4a41-98e1-b6b83f6cf8cf.png" width="807" />
  </figure>
  <figure class="m_original">
    <img src="https://imgprx.livejournal.net/b6abb2974a1577279a7315a4989e8580f0866972/MLPZu1E7P23kNdNPsSKwnvOtLw_zn1Z4sgWzWrnq9OyUVoIFGjGri_8Yn_k-E5-8lVg2AOyJ4L9E_gWpK3WiWtS2N909vuOaWu5_gGx1hkyZ7t-QPxSY6J3QoYnxwWoPIfzIS__n5CF6bks9xx_MbxmaNYP3BNaKNMK1RItXm4k" width="674" />
  </figure>
  <h2>// Lesson 6 // Составные операторы присвоения</h2>
  <p>var <strong>c</strong> = <strong>1</strong></p>
  <p><strong>c</strong> <strong>+=</strong> 2 // += составной оператор с + 2 = 3 ( с=1 то есть c+=2 получается 3 )</p>
  <p>c = c + 2 // c=3 строкой выше с+2 где с (3) + 2 =5</p>
  <p>var count = 6 // count - перевод &quot;считать&quot;</p>
  <p>count += 1 // ответ 7 / 6 считать + 1 (считать count (6) += 1) ответ 7</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/ab/24/ab24eb97-e0db-4c52-bb19-d7fef4c7275c.png" width="871" />
  </figure>
  <h2>// Lesson 7 <strong>// Операторы сравнения </strong></h2>
  <p>// == равно / != не равно / &gt; больше / &lt; меньше /</p>
  <p>// &gt;= больше или равно / &lt;= меньше или равно</p>
  <pre data-lang="swift">let t = 15
let p = 10</pre>
  <p>t == p // <strong>false</strong> лож или неверно (не равно) 15=10 (false ==)</p>
  <p>t != p // <strong>true</strong> правда или да (верно, не равно) 15 не равно 10 (true !=)</p>
  <p>t &gt; p</p>
  <p>t &lt; p</p>
  <p>t &gt;= p</p>
  <p>t &lt;= p</p>
  <p></p>
  <pre>let name = &quot;world&quot;                      // let Константа «world»</pre>
  <pre>if name == &quot;world&quot; {                    // if если = world (True)</pre>
  <pre>print(&quot;Hello, world!&quot;)                  // то печатаем Hello, world!</pre>
  <pre>} else {                                // else ещё (другое что-то)</pre>
  <pre>print(&quot;Something went wrong&quot;)           // то печатаем Something went wrong</pre>
  <pre>}</pre>
  <p>// Ответ: Hello, world!</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/fd/ac/fdac4182-a7cb-4edd-8c61-d165c3843832.png" width="760" />
  </figure>
  <h2>// Lesson 8 // Тернарный (?) / Условный оператор</h2>
  <p>// Выражение <strong>?</strong>  / действие 1 : действие 2</p>
  <p><strong> if</strong> выражение {</p>
  <p>действие 1</p>
  <p>} <strong>else</strong> {</p>
  <p>действие 2</p>
  <p>}</p>
  <p></p>
  <pre>let firstCard = 11                 // Первая карта = 11</pre>
  <pre>let secondCard = 10                // Вторая карта = 10</pre>
  <pre>if firstCard == secondCard {       // if если первая карта = второй карте</pre>
  <pre>print(&quot;Cards are the same&quot;)        // печатаем («Карты одинаковы»)</pre>
  <pre>} else {                    // else еще (другое) в том случае если не равно</pre>
  <pre>print(&quot;Cards are different&quot;)       // печатаем («Карты разные»)</pre>
  <pre>}</pre>
  <p><strong>// Этаже запись с помощью тернарного оператора (?) он же ==</strong></p>
  <p>firstCard == secondCard <strong>?</strong> print(&quot;Cards are the same&quot;) : print(&quot;Cards are different&quot;)</p>
  <p><strong>// Если не равно</strong></p>
  <p>firstCard != secondCard ? print(&quot;Cards are the same&quot;) : print(&quot;Cards are different&quot;)</p>
  <p><strong>// Ответ видим в коде.</strong></p>
  <figure class="m_original">
    <img src="https://teletype.in/files/46/c4/46c4aaca-4e8c-4660-9c7f-aea53b0d383a.png" width="837" />
  </figure>
  <pre data-lang="swift">var gender = 1
gender == 0 ? print(&quot;male&quot;) : print(&quot;famaly&quot;)

var fruits = 2
fruits == 0 ? print(&quot;apple&quot;) : print(&quot;mango&quot;)

gender; index
fruits; index</pre>
  <p>// Попробуйте <strong>не равно</strong> fruits <strong>!=</strong> 0 ? print(&quot;apple&quot;) : print(&quot;mango&quot;)</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/28648/28648_original.png" width="770" />
    <figcaption>Что будет: fruits != 0 ? print(&quot;apple&quot;) : print(&quot;mango&quot;)</figcaption>
  </figure>
  <h2>// Lesson 9 // Оператор замкнутого/закрытого диапазона (a...b),</h2>
  <h2>// Оператор полузамкнутого/полузакрытого диапазона (a..&lt;b) не включая Б b</h2>
  <p>// Видео</p>
  <p>// Логические операторы / ! — не, !a — (не a) / &amp;&amp; — и / || — или</p>
  <pre>let areYouHappy = true          // константа выСчаствиы = да</pre>
  <pre>if !areYouHappy {               // if — если !выСчаствивы / где ! — не</pre>
  <pre>print(&quot;Good, for you&quot;)          // false печатаем(«Повезло, тебе»)</pre>
  <pre>} else {                        // else — ещё</pre>
  <pre>print(&quot;What can a do for you?&quot;) // true печатаем(«Чем можем помочь?»)</pre>
  <pre>}</pre>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/2570/2570_800.png" width="800" />
    <figcaption>let areYouHappy = true</figcaption>
  </figure>
  <p><strong>// Другой пример &amp;&amp; / и</strong></p>
  <pre data-lang="swift">let areYouHappy = true
let isTheWeatherGood = true

if areYouHappy &amp;&amp; isTheWeatherGood {
print(&quot;Go outside&quot;) 
} else {
print(&quot;Stay home&quot;) 
}</pre>
  <p>// true / areYouHappy = true <strong>и</strong> isTheWeatherGood = true</p>
  <p>// true / не выполняется поскольку первое исполнено</p>
  <p><strong>// Другой пример || / или</strong></p>
  <pre data-lang="swift">let isTheWeatherGood2 = true

if areYouHappy || isTheWeatherGood2 {
print(&quot;Go outside&quot;)
} else {
print(&quot;Stay home&quot;) 
}</pre>
  <p>// true / areYouHappy good = true</p>
  <p>// true / не выполняется поскольку первое исполнен</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/4b/42/4b423ffd-64f6-40d9-84db-ce8a241497ea.png" width="902" />
  </figure>
  <h2>// Lesson 10 // Условия</h2>
  <p>// Видео <a href="https://www.youtube.com/watch?v=ZJcVUSfdVyo&t=3580s" target="_blank">59:40</a>​ Условия</p>
  <p><strong>// Пример 1</strong></p>
  <pre data-lang="swift">let firstCard = 11</pre>
  <pre data-lang="swift">let secondCard = 10</pre>
  <pre data-lang="swift">if firstCard + secondCard == 21 {</pre>
  <pre data-lang="swift">print(&quot;You are win&quot;)</pre>
  <pre data-lang="swift">} else if (firstCard + secondCard) &gt; 18 &amp;&amp; (firstCard + secondCard) &lt; 21 {</pre>
  <pre data-lang="swift">print(&quot;Good cards&quot;)</pre>
  <pre data-lang="swift">} else {</pre>
  <pre data-lang="swift">print(&quot;Regular cards&quot;)</pre>
  <pre>}</pre>
  <p>// Условие при котором печатается «<strong>You are win</strong>»</p>
  <p>// <strong>if</strong>  firstCard + secondCard == <strong>21 (первое условие)</strong></p>
  <p>// Второе условие<strong> не выполняется</strong> поскольку уже выполнилось первое.</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/3941/3941_original.png" width="717" />
    <figcaption>Условие 1</figcaption>
  </figure>
  <p><strong>// Пример 2</strong></p>
  <p>// Изменим наши константы:</p>
  <pre>let firstCard = 11</pre>
  <pre data-lang="swift">let secondCard = 8</pre>
  <pre data-lang="swift">if firstCard + secondCard == 21 {</pre>
  <pre data-lang="swift">print(&quot;You are win&quot;)</pre>
  <pre data-lang="swift">} else if (firstCard + secondCard) &gt; 18 &amp;&amp; (firstCard + secondCard) &lt; 21 {</pre>
  <pre data-lang="swift">print(&quot;Good cards&quot;)</pre>
  <pre data-lang="swift">} else {</pre>
  <pre data-lang="swift">print(&quot;Regular cards&quot;)</pre>
  <pre data-lang="swift">}</pre>
  <p>// Условие при котором печатается «<strong>Good cards</strong>»</p>
  <p>// ( 11+8=19 ) 19&gt;18 ( 11+8=19 ) 19&lt;21</p>
  <p>//(firstCard + secondCard) &gt; 18 &amp;&amp; (firstCard + secondCard) &lt; 21</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/4110/4110_original.png" width="743" />
    <figcaption>Условие 2</figcaption>
  </figure>
  <p><strong>// Пример 3</strong></p>
  <pre data-lang="swift">let age1 = 12</pre>
  <pre data-lang="swift">let age2 = 21</pre>
  <pre>if age1 &gt; 12 &amp;&amp; age2 &gt; 18 {    // Распечатается если все условие будет True</pre>
  <pre data-lang="swift">print(&quot;Both are over 18&quot;)</pre>
  <pre data-lang="swift">}</pre>
  <pre>if age1 &gt; 12 || age2 &gt; 18 {    // Распечатается если одно условие True</pre>
  <pre data-lang="swift">print(&quot;Both are over 18&quot;)</pre>
  <pre data-lang="swift">}</pre>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/4799/4799_original.png" width="698" />
    <figcaption>Пример 3</figcaption>
  </figure>
  <p><strong>// Switch</strong> — переключатель.</p>
  <p>switch (переключатель) значение для сопоставления {</p>
  <p>case значение 1:</p>
  <p>инструкция для значения 1</p>
  <p>case значение 2:</p>
  <p>инструкция для значения 2</p>
  <p>case значение 3:</p>
  <p>инструкция для значения 3</p>
  <p>default:</p>
  <p>инструкция, если значения с шаблонами не найдены (не совпадают)</p>
  <p>}</p>
  <p><strong>// Пример 1</strong></p>
  <pre data-lang="swift">let weather = &quot;sunny&quot;</pre>
  <pre data-lang="swift">switch weather {</pre>
  <pre data-lang="swift">case &quot;rain&quot;: print(&quot;Ring an umbrella&quot;)</pre>
  <pre data-lang="swift">case &quot;sniw&quot;: print(&quot;Wrap up warm&quot;)</pre>
  <pre data-lang="swift">case &quot;sunny&quot;: print(&quot;Wear glasses&quot;)</pre>
  <pre data-lang="swift">case &quot;clouds&quot;: print(&quot;Maybe rain&quot;)</pre>
  <pre data-lang="swift">default: print(&quot;Enjoy your day&quot;) //Если ничего не подходит выводим это.</pre>
  <pre data-lang="swift">}</pre>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/4905/4905_original.png" width="738" />
    <figcaption>Case</figcaption>
  </figure>
  <p>// Вводим значение: <strong>fallthrough</strong> (Терпеть неудачу)</p>
  <p>// В таком случаем выводится строка ниже.</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/5373/5373_original.png" width="738" />
    <figcaption>Case 2</figcaption>
  </figure>
  <p>// Вводим константу <strong>age</strong> = 12</p>
  <pre data-lang="swift">let age = 12</pre>
  <pre data-lang="swift">switch age {</pre>
  <pre data-lang="swift">case 0...10: print(&quot;You are too young&quot;)</pre>
  <pre data-lang="swift">case 13..&lt;20: print(&quot;Yoy are teenager&quot;)</pre>
  <pre data-lang="swift">case 20...60: print(&quot;You are grown man&quot;)</pre>
  <pre data-lang="swift">default: print(&quot;How old are you&quot;)</pre>
  <pre data-lang="swift">}</pre>
  <p>// Как думаете что выведется при компиляции?</p>
  <p>// Распечаталось How old are you (сколько тебе лет)</p>
  <p>// Потому что не указан диапазон от 10...13</p>
  <p>// Выводится <strong>default</strong></p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/5405/5405_original.png" width="747" />
    <figcaption>Case 3</figcaption>
  </figure>
  <pre data-lang="swift">let age = 80 // или больше 80...</pre>
  <pre data-lang="swift">case 80...: print(&quot;You are old man&quot;)</pre>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/5922/5922_original.png" width="748" />
    <figcaption>Case 4</figcaption>
  </figure>
  <h2>// Lesson 12 / Циклы / Cycles</h2>
  <p>// for in / while / repeat-while / <a href="https://swiftbook.ru/content/7-video-19/" target="_blank">(Смотреть)</a></p>
  <p>// Видео <a href="https://www.youtube.com/watch?v=ZJcVUSfdVyo&t=4519s" target="_blank">1:15:19</a>​ Циклы</p>
  <figure class="m_original">
    <img src="https://teletype.in/files/e4/ff/e4ff5e9a-cb49-4497-9ec6-9637e9ea3f85.png" width="696" />
  </figure>
  <p><strong>// Пример 1 </strong>/ for in /</p>
  <pre>let count = 1...10           // count (считать) Включая число 1 и число 10</pre>
  <pre>for number in count {</pre>
  <pre>print(&quot;Number is \(number)&quot;) // Метод конкатенации</pre>
  <pre>}</pre>
  <p>// Распечаталось 10 цифр.</p>
  <p><strong>// Итерация</strong> — повторение одного и того же действия.</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/6303/6303_original.png" width="776" />
    <figcaption>Cycles 1 / for in</figcaption>
  </figure>
  <p><strong>// number</strong> можем заменить на любое имя (<strong>allName</strong>) (i) (numeral) и.т.д.</p>
  <p>// Это — внутренняя константа, используется только внутри тела цикла.</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/6473/6473_800.png" width="800" />
    <figcaption>Cycles 2 / for in</figcaption>
  </figure>
  <p><strong>// Пример 2 </strong>/ for in /</p>
  <pre data-lang="swift">for _ in 1...5 {</pre>
  <pre data-lang="swift">print(&quot;Hello&quot;)</pre>
  <pre data-lang="swift">}</pre>
  <p>// Распечатать Hello 5 раз (Итерация)</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/6817/6817_original.png" width="710" />
    <figcaption>Cycles 3 / for in</figcaption>
  </figure>
  <p>// <strong>Пример 3 </strong>/ for in /</p>
  <pre data-lang="swift">for index in 0...9 {</pre>
  <pre data-lang="swift">print(&quot;\(index) умножить на 3 равно \(index * 3)&quot;)</pre>
  <pre data-lang="swift">}</pre>
  <p>// Итерация с использованием ( <strong>*</strong> ) умножения</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/6934/6934_original.png" width="701" />
    <figcaption>Cycles 4 / for in</figcaption>
  </figure>
  <p>// <strong>Пример 4</strong> / while /</p>
  <p>// Если условие истинно <strong>True</strong> то выполняется пока не станет <strong>False</strong></p>
  <pre data-lang="swift">while условие {</pre>
  <pre>инструкция</pre>
  <pre data-lang="swift">}</pre>
  <p>// Запишем</p>
  <pre data-lang="swift">var number = 1 </pre>
  <pre data-lang="swift">while number &lt;= 20 {</pre>
  <pre data-lang="swift">print(number)</pre>
  <pre data-lang="swift">number += 1</pre>
  <pre data-lang="swift">}</pre>
  <pre data-lang="swift">print(&quot;Start&quot;)</pre>
  <p>// Выполнять до тех пор пока меньше &lt; или = 20 (<strong>True</strong>)</p>
  <p>// и печатать (это значение)</p>
  <p>// каждую итерацию прибавлять +1</p>
  <p>// как только станет больше &gt; или =20 (<strong>False</strong>) напечатать «Start»</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/7336/7336_800.png" width="800" />
    <figcaption>Cycles 5 / while</figcaption>
  </figure>
  <p>// <strong>Пример 5</strong> / <strong>repeat-while</strong> / в других языках«<em>do while</em>»</p>
  <pre data-lang="swift">repeat {</pre>
  <pre data-lang="swift">инструкция</pre>
  <pre data-lang="swift">} while условие</pre>
  <p>// Запишем</p>
  <pre data-lang="swift">var number = 10</pre>
  <pre data-lang="swift">repeat {</pre>
  <pre data-lang="swift">print(number)</pre>
  <pre data-lang="swift">number += 1</pre>
  <pre data-lang="swift">} while number &lt;= 20</pre>
  <pre data-lang="swift">print(&quot;Start&quot;)</pre>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/7545/7545_original.png" width="716" />
    <figcaption>Cycles 6 / repeat</figcaption>
  </figure>
  <p>// <strong>Пример 6</strong> / <strong>repeat-while</strong> /</p>
  <pre data-lang="swift">var number = 10</pre>
  <pre data-lang="swift">repeat {</pre>
  <pre data-lang="swift">print(number)</pre>
  <pre data-lang="swift">number += 1</pre>
  <pre data-lang="swift">} while number &lt;= 5</pre>
  <pre data-lang="swift">print(&quot;Finish&quot;)</pre>
  <p>// В данном случае число <strong>10</strong> уже прошло проверку.</p>
  <p>// <strong>repeat </strong>(повторять) = 10 (<strong>True</strong>)</p>
  <p>// и печатать (это значение)</p>
  <p>// каждую итерацию прибавлять +1</p>
  <p>// как только станет равно = 10 (<strong>False</strong>) напечатать «Finish»</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/7860/7860_800.png" width="800" />
    <figcaption>Cycles 7 / repeat</figcaption>
  </figure>
  <p>// <strong>Пример 7</strong> / <strong>repeat-while</strong> / Отсчитать до старта /</p>
  <pre data-lang="swift">var start = 10</pre>
  <pre data-lang="swift">while start &gt;= 0 {</pre>
  <pre data-lang="swift">print(start)</pre>
  <pre data-lang="swift">start -= 1</pre>
  <pre data-lang="swift">}</pre>
  <pre data-lang="swift">print(&quot;Go, go!&quot;)</pre>
  <p>// Задача отсчитать время до старта в обратном порядке.</p>
  <p>// <strong>while </strong>(пока) start больше или равен &gt;= 0</p>
  <p>// печатать (значения <strong>start</strong>)</p>
  <p>// При каждой итерации отнимая (start <strong>10</strong>) -1 (start -= 1)</p>
  <p>// Все числа 10,9,8......3,2,1,0 (<strong>True</strong>)</p>
  <p>// Как только значение станет (<strong>False</strong>) напечатать «Go, go!»</p>
  <figure class="m_original">
    <img src="https://ic.pics.livejournal.com/udarcs/88244882/8188/8188_original.png" width="747" />
    <figcaption>Cycles 8 / repeat</figcaption>
  </figure>
  <p>​</p>
  <h2><strong><a href="https://teletype.in/@udarcs/TyDy3dzCr01" target="_blank">// Продолжение / Часть 2 / ( ПЕРЕЙТИ)</a></strong></h2>

]]></content:encoded></item></channel></rss>