<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; CMD/BAT: Код минимальной длинны]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9292&amp;type=atom" />
	<updated>2014-02-24T07:47:21Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9292</id>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80338#p80338" />
			<content type="html"><![CDATA[<p><strong>Yury</strong>, только это решение проигрывает по длине такому:<br /></p><div class="codebox"><pre><code>for /f &quot;tokens=1-3&quot; %a in (&#039;type i*&#039;) do set /a %a*%b*%c*2&gt;output.txt</code></pre></div><p>Думал как бы этот проблем легко свести на нет, к примеру, если приписать в конце 1, то получится *1. Но если пробела в конце нет, то 1 допишется к самому числу.</p>]]></content>
			<author>
				<name><![CDATA[Arigato]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29277</uri>
			</author>
			<updated>2014-02-24T07:47:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80338#p80338</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80331#p80331" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Arigato пишет:</cite><blockquote><p>Гарантированно там нет других файлов, начинающихся на i.</p></blockquote></div><p>Ну, в условии задачи об этом ничего не было сказано. Потому вызвало удивление.</p><div class="quotebox"><cite>Arigato пишет:</cite><blockquote><p>Вот только проблема в том, что в файле input.txt может оказаться пробел в конце строки</p></blockquote></div><p>Данное условие также отсутствует в техзадании <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-24T00:19:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80331#p80331</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80329#p80329" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Arigato пишет:</cite><blockquote><p>Вот только проблема в том, что в файле input.txt может оказаться пробел в конце строки, тогда получается &quot;14*23*5*&quot; и не работает. Как бы его отрезать.</p></blockquote></div><div class="codebox"><pre><code>set /p x=&lt;input.txt&amp; (&gt;nul findstr /rc:&quot; \&gt;&quot; input.txt&amp;&amp; call set /a 2*%x: =*%1|| call set /a 2*%x: =*%)&gt;output.txt</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2014-02-23T21:09:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80329#p80329</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80309#p80309" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p><strong>Arigato</strong>, а ежели там ещё на «i» окажутся файлы? Некорректно.</p></blockquote></div><p>Гарантированно там нет других файлов, начинающихся на i.</p><div class="quotebox"><cite>alexii пишет:</cite><blockquote><p>Можно сократить на пару символов, убрав «x=». Ещё один — использовав «tokens=1-3» вместо «tokens=1,2*».</p></blockquote></div><p>Да, спасибо, 3 символа убрали.</p><div class="quotebox"><blockquote><p>у меня без «call» не работает</p></blockquote></div><p>Я тоже такой вариант пытался реализовать, то же ругался на отсутствующий операнд. С call работает, спасибо за подсказку. Вот только проблема в том, что в файле input.txt может оказаться пробел в конце строки, тогда получается &quot;14*23*5*&quot; и не работает. Как бы его отрезать.</p>]]></content>
			<author>
				<name><![CDATA[Arigato]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29277</uri>
			</author>
			<updated>2014-02-23T13:17:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80309#p80309</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80307#p80307" />
			<content type="html"><![CDATA[<p><strong>Yury</strong>, угу. Только через реестр задано.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-23T13:09:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80307#p80307</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80305#p80305" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p>у меня без «call» не работает</p></blockquote></div><p><strong>alexii</strong>, у Вас интерпретатор запускаеся с параметром &quot;<strong>/v:on</strong>&quot;.</p>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2014-02-23T13:03:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80305#p80305</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80304#p80304" />
			<content type="html"><![CDATA[<p><strong>Yury</strong>, у меня без «call» не работает:<br /></p><div class="quotebox"><blockquote><p>Отсутствующий операнд.</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-23T12:31:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80304#p80304</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80303#p80303" />
			<content type="html"><![CDATA[<p>Нашёл:<br /></p><div class="codebox"><pre><code>set /p s=&lt;input.txt&amp;call set /a 2*%s: =*%&gt;output.txt</code></pre></div><p><em>Update:</em> Опоздал <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-23T12:28:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80303#p80303</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80302#p80302" />
			<content type="html"><![CDATA[<p>Без пробелов 42 символа: </p><div class="codebox"><pre><code>set /p x=&lt;input.txt&amp; set /a 2*%x: =*%&gt;output.txt</code></pre></div><p>.</p><p>A такой код можно вставить и в пакетный файл: </p><div class="codebox"><pre><code>cmd /v:on /c &quot;set /p x=&lt;input.txt&amp; set /a x=2*!x: =*!&gt;output.txt</code></pre></div><p>P. S. Я не случайно упустил закрывающую кавычку. Если уж речь идёт о минимализации кода, то хватит и одной.</p>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2014-02-23T12:26:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80302#p80302</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80301#p80301" />
			<content type="html"><![CDATA[<p><strong>Arigato</strong>, а ежели там ещё на «i» окажутся файлы? Некорректно.</p><p>Можно сократить на пару символов, убрав «x=». Ещё один — использовав «tokens=1-3» вместо «tokens=1,2*».</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-23T12:20:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80301#p80301</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[CMD/BAT: Код минимальной длинны]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80295#p80295" />
			<content type="html"><![CDATA[<p>Задача: в файле input.txt записаны 3 целых числа через пробелы (a b c).<br />Необходимо вывести в файл output.txt значение 2*a*b*c.<br />Например:<br />input.txt: 5 2 3 =&gt; output.txt: 60<br />input.txt: 14 23 5 =&gt; output.txt: 3220</p><p>Задачу необходимо решить в виде одной команды, вводимой непосредственно в командной строке. При этом необходимо уменьшить количество непробельных символов до минимума (пробелы, табуляции не считаем).</p><p>Вот что получилось у меня:</p><div class="codebox"><pre><code>for /f &quot;tokens=1,2*&quot; %a in (&#039;type i*&#039;) do set /a x=2*%a*%b*%c&gt;output.txt</code></pre></div><p>Без пробелов 62 символа. Есть ли идеи по уменьшению кода?</p>]]></content>
			<author>
				<name><![CDATA[Arigato]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29277</uri>
			</author>
			<updated>2014-02-23T10:26:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80295#p80295</id>
		</entry>
</feed>
