84 lines
5.6 KiB
XML
84 lines
5.6 KiB
XML
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||
<channel>
|
||
<title>Cheat Sheets on SWangNice</title>
|
||
<link>http://localhost:1313/notes/coding/cheat_sheet/</link>
|
||
<description>Recent content in Cheat Sheets on SWangNice</description>
|
||
<generator>Hugo -- gohugo.io</generator>
|
||
<language>en</language>
|
||
<copyright>© 2025 SWang</copyright>
|
||
<lastBuildDate>Fri, 20 Sep 2024 04:17:50 +0000</lastBuildDate><atom:link href="http://localhost:1313/notes/coding/cheat_sheet/index.xml" rel="self" type="application/rss+xml" />
|
||
|
||
<item>
|
||
<title>C</title>
|
||
<link>http://localhost:1313/notes/coding/cheat_sheet/c/</link>
|
||
<pubDate>Fri, 20 Sep 2024 04:17:50 +0000</pubDate>
|
||
|
||
<guid>http://localhost:1313/notes/coding/cheat_sheet/c/</guid>
|
||
<description><!-- 笔试题有的时候不给正常输入,只给plain text -->
|
||
|
||
|
||
<h2 class="relative group">Format Specifier
|
||
<div id="format-specifier" class="anchor"></div>
|
||
|
||
<span
|
||
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100">
|
||
<a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700"
|
||
style="text-decoration-line: none !important;" href="#format-specifier" aria-label="Anchor">#</a>
|
||
</span>
|
||
|
||
</h2>
|
||
<p>Common specifiers:</p>
|
||
<pre tabindex="0"><code>%d int
|
||
%u unsigned int
|
||
%c char
|
||
%s string (char s[])
|
||
%p void*
|
||
%ld long
|
||
%lld long long (64bits)
|
||
%f float/double
|
||
%lf float/double(usually used in scanf)
|
||
</code></pre><p>We can extend the format specifiers:</p>
|
||
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-C" data-lang="C"><span class="line"><span class="cl"><span class="nf">printf</span><span class="p">(</span><span class="s">&#34;%5d&#34;</span><span class="p">,</span> <span class="mi">33</span><span class="p">);</span> <span class="c1">// width &#34; 33&#34;
|
||
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nf">printf</span><span class="p">(</span><span class="s">&#34;%.2f&#34;</span><span class="p">,</span> <span class="mf">3.14159</span><span class="p">);</span> <span class="c1">// precision &#34;3.14&#34;
|
||
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nf">printf</span><span class="p">(</span><span class="s">&#34;%8.2f&#34;</span><span class="p">,</span> <span class="mf">3.14159</span><span class="p">);</span><span class="c1">// &#34; 3.14&#34;
|
||
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nf">printf</span><span class="p">(</span><span class="s">&#34;%-5d&#34;</span><span class="p">,</span> <span class="mi">33</span><span class="p">);</span> <span class="c1">//Alignment &#34;33 &#34;
|
||
</span></span></span></code></pre></div>
|
||
|
||
<h2 class="relative group">IO
|
||
<div id="io" class="anchor"></div>
|
||
|
||
<span
|
||
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100">
|
||
<a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700"
|
||
style="text-decoration-line: none !important;" href="#io" aria-label="Anchor">#</a>
|
||
</span>
|
||
|
||
</h2>
|
||
<p>Read or print via terminal:</p></description>
|
||
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="http://localhost:1313/notes/coding/cheat_sheet/c/feature.png" />
|
||
</item>
|
||
|
||
<item>
|
||
<title>C++</title>
|
||
<link>http://localhost:1313/notes/coding/cheat_sheet/cpp/</link>
|
||
<pubDate>Fri, 20 Sep 2024 04:17:50 +0000</pubDate>
|
||
|
||
<guid>http://localhost:1313/notes/coding/cheat_sheet/cpp/</guid>
|
||
<description></description>
|
||
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="http://localhost:1313/notes/coding/cheat_sheet/cpp/feature.png" />
|
||
</item>
|
||
|
||
<item>
|
||
<title>Python</title>
|
||
<link>http://localhost:1313/notes/coding/cheat_sheet/python/</link>
|
||
<pubDate>Fri, 20 Sep 2024 04:17:50 +0000</pubDate>
|
||
|
||
<guid>http://localhost:1313/notes/coding/cheat_sheet/python/</guid>
|
||
<description></description>
|
||
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="http://localhost:1313/notes/coding/cheat_sheet/python/feature.png" />
|
||
</item>
|
||
|
||
</channel>
|
||
</rss>
|