2024-07-24 09:39:31 +02:00
import { _ as s , c as i , o as a , a6 as n } from "./chunks/framework.CZKtKhAm.js" ; const l = "/c/assets/1.L8V3GBrc.png" , p = "/c/assets/2.BkF1yWLn.png" , t = "/c/assets/3.CceY8r_n.png" , h = "/c/assets/4.DHaUgOwj.png" , k = "/c/assets/5.CXGaq_zh.png" , e = "/c/assets/6.BrZYAEEl.png" , r = "/c/assets/7.DpCroFHv.png" , d = "/c/assets/8.Cr7P0Gji.png" , E = "/c/assets/9.NlBmD7pA.png" , c = "/c/assets/10.ZiBq6Pno.png" , g = "/c/assets/11.DAgmsf-w.png" , F = "/c/assets/12.B2iC37fw.png" , y = "/c/assets/14.BlE3ZFud.png" , u = "/c/assets/15.CdvhiwcU.png" , b = "/c/assets/16.D74t3-Xt.png" , o = "/c/assets/17.DdAZIfeP.png" , C = "/c/assets/18.B4Zfj2jX.png" , m = "/c/assets/19.IfpA0D5n.png" , B = "/c/assets/20.CfIzYazX.png" , A = "/c/assets/21.eHnZcbpI.png" , D = "/c/assets/22.BNoKlM4o.png" , v = "/c/assets/23.CMVtwrqr.png" , q = "/c/assets/24.CN19KJG7.png" , f = "/c/assets/25.BIhiJHjz.png" , _ = "/c/assets/26.A_E4n4g8.png" , x = "/c/assets/27.Bv4qFbwF.png" , z = "/c/assets/28.IKaazo2J.png" , w = "/c/assets/29.CGTVELeO.png" , I = "/c/assets/30.Bz4_lEH0.gif" , P = "/c/assets/31.CcDWE4nn.png" , T = "/c/assets/32.B7y2_JVX.gif" , N = "/c/assets/33.Btcc3rs2.gif" , L = "/c/assets/34.CR4ARW8y.png" , O = "/c/assets/33.Btcc3rs2.gif" , S = "/c/assets/36.DOX3ymYP.gif" , U = "/c/assets/37.Cie9_tkP.gif" , M = "/c/assets/38.DLjH9Ges.png" , $ = JSON . parse ( '{"title":"第一章:数据类型(⭐)","description":"","frontmatter":{},"headers":[],"relativePath":"notes/01_c-basic/03_xdx/index.md","filePath":"notes/01_c-basic/03_xdx/index.md","lastUpdated":1721697894000}' ) , X = { name : "notes/01_c-basic/03_xdx/index.md" } , R = n ( '<h1 id="第一章-数据类型-⭐" tabindex="-1">第一章:数据类型(⭐) <a class="header-anchor" href="#第一章-数据类型-⭐" aria-label="Permalink to "第一章:数据类型(⭐)""> </a></h1><h2 id="_1-1-概述" tabindex="-1">1.1 概述 <a class="header-anchor" href="#_1-1-概述" aria-label="Permalink to "1.1 概述""> </a></h2><ul><li><p>根据<code>变量</code>中<code>存储</code>的<code>值</code>的<code>不同</code>,我们可以将<code>变量</code>分为两类:</p><ul><li><code>普通变量</code>:变量所对应的内存中存储的是<code>普通值</code>。</li><li><code>指针变量</code>:变量所对应的内存中存储的是<code>另一个变量的地址</code>。</li></ul></li><li><p>如下图所示:</p></li></ul><p><img src="' + l + '" alt=""></p><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p><p></p><p>普通变量和指针变量的相同点:</p><ul><li>普通变量有内存空间,指针变量也有内存空间。</li><li>普通变量有内存地址,指针变量也有内存地址。</li><li>普通变量所对应的内存空间中有值,指针变量所对应的内存空间中也有值。</li></ul><p>普通变量和指针变量的不同点:</p><ul><li>普通变量所对应的内存空间存储的是普通的值,如:整数、小数、字符等;指针变量所对应的内存空间存储的是另外一个变量的地址。</li><li>普通变量有普通变量的运算方式,而指针变量有指针变量的运算方式(后续讲解)。</li></ul></div><ul><li>那么,在 C 语言中变量的数据类型就可以这么划分,如下所示:</li></ul><p><img src="' + p + ` " alt=""></p><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p><p></p><ul><li>根据<code>普通变量</code>中<code>存储</code>的<code>值</code>的类型不同,可以将<code>普通变量类型</code>划分为<code>基本数据类型</code>(整型、字符类型、浮点类型、布尔类型)和<code>复合数据类型</code>(数组类型、结构体类型、共用体类型、枚举类型)。</li><li>根据<code>指针变量</code>所<code>指向空间</code>中<code>存储</code>的<code>值</code>的类型不同,可以将<code>指针类型</code>分为<code>基本数据类型指针</code>、<code>复合数据类型指针</code>、<code>函数指针</code>、<code>数组指针</code>等,例如:如果指针所指向的空间保存的是 int 类型,那么该指针就是 int 类型的指针。</li></ul></div><h2 id="_1-2-整数类型" tabinde
2024-07-19 09:46:50 +02:00
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义有符号 short 类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > signed < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s h o r t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / s 1 = - 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义无符号 short 类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s h o r t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / s 2 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义 short 类型,默认是有符号</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > short < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / s 3 = - 2 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 获 取 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > u n s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s h o r t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d s h o r t 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 2 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s h o r t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s i g n e d s h o r t 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 2 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s h o r t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s h o r t 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 2 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 获 取 类 型 的 取 值 范 围 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; l i m i t s . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d s h o r t 类 型 的 范 围 是 [ 0 , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , U S H R T _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ 0 , 6 5 5 3 5 ] < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s h o r t 类 型 的 范 围 是 [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , S H R T _ M I N , S H R T _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ - 3 2 7 6 8 , 3 2 7 6 7 ] < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 2 - 3 - 整 型 " t a b i n d e x = " - 1 " > 1 . 2 . 3 整 型 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 2 - 3 - 整 型 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 2 . 3 整 型 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 语 法 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > u n s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 无 符 号 整 型 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 有 符 号 整 型 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 有 符 号 表 示 的 是 正 数 、 负 数 和 0 , 即 有 正 负 号 。 无 符 号 表 示 的 是 0 和 正 数 , 即 正 整 数 , 没 有 符 号 。 < / l i > < l i > ② 在 < c o d e > p r i n t f < / c o d e > 中 < c o d e > 无 符 号 整 型 ( u n s i g n e d i n t ) < / c o d e > 的 < c o d e > 格 式 占 位 符 < / c o d e > 是 < c o d e > % u < / c o d e > , < c o d e > 有 符 号 整 型 ( s i g n e d i n t ) < / c o d e > 的 < c o d e > 格 式 占 位 符 < / c o d e > 是 < c o d e > % d < / c o d e > 。 < / l i > < l i > ③ 可 以 通 过 < c o d e > s i z e o f < / c o d e > 运 算 符 获 取 < c o d e > 无 符 号 整 型 ( u n s i g n e d i n t ) < / c o d e > 和 < c o d e > 有 符 号 整 型 ( s i g n e d i n t ) < / c o d e > 的 < c o d e > 存 储 空 间 ( 所 占 内 存 空 间 ) < / c o d e > 。 < / l i > < l i > ③ 可 以 通 过 < c o d e > # i n c l u d e & l t ; l i m i t s . h & g t ; < / c o d e > 来 获 取 < c o d e > 无 符 号 整 型 ( u n s i g n e d i n t ) < / c o d e > 和 < c o d e > 有 符 号 整 型 ( s i g n e d i n t ) < / c o d e > 的 < c o d e > 取 值 范 围 < / c o d e > 。 < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : 定 义 和 打 印 整 型 变 量 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义有符号 int 类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > signed < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i 1 = - 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义无符号 int 类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i 2 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义 int 类型,默认是有符号</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > short < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i 3 = - 2 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 获 取 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > u n s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d i n t 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s i g n e d i n t 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i n t 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 获 取 类 型 的 取 值 范 围 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; l i m i t s . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d i n t 类 型 的 范 围 是 [ 0 , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , U I N T _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ 0 , 4 2 9 4 9 6 7 2 9 5 ] < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i n t 类 型 的 范 围 是 [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , I N T _ M I N , I N T _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ - 2 1 4 7 4 8 3 6 4 8 , 2 1 4 7 4 8 3 6 4 7 ] < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 2 - 4 - 长 整 型 - 了 解 " t a b i n d e x = " - 1 " > 1 . 2 . 4 长 整 型 ( 了 解 ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 2 - 4 - 长 整 型 - 了 解 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 2 . 4 长 整 型 ( 了 解 ) & q u o t ; " > < / a > < / h 3 > < u l > < l i > 语 法 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > u n s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 无 符 号 长 整 型 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 有 符 号 长 整 型 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 有 符 号 表 示 的 是 正 数 、 负 数 和 0 , 即 有 正 负 号 。 无 符 号 表 示 的 是 0 和 正 数 , 即 正 整 数 , 没 有 符 号 。 < / l i > < l i > ② 在 < c o d e > p r i n t f < / c o d e > 中 < c o d e > 无 符 号 长 整 型 ( u n s i g n e d l o n g ) < / c o d e > 的 < c o d e > 格 式 占 位 符 < / c o d e > 是 < c o d e > % l u < / c o d e > , < c o d e > 有 符 号 长 整 型 ( s i g n e d l o n g ) < / c o d e > 的 < c o d e > 格 式 占 位 符 < / c o d e > 是 < c o d e > % l d < / c o d e > 。 < / l i > < l i > ③ 可 以 通 过 < c o d e > s i z e o f < / c o d e > 运 算 符 获 取 < c o d e > 无 符 号 长 整 型 ( u n s i g n e d l o n g ) < / c o d e > 和 < c o d e > 有 符 号 长 整 型 ( s i g n e d l o n g ) < / c o d e > 的 < c o d e > 存 储 空 间 ( 所 占 内 存 空 间 ) < / c o d e > 。 < / l i > < l i > ③ 可 以 通 过 < c o d e > # i n c l u d e & l t ; l i m i t s . h & g t ; < / c o d e > 来 获 取 < c o d e > 无 符 号 长 整 型 ( u n s i g n e d l o n g ) < / c o d e > 和 < c o d e > 有 符 号 长 整 型 ( s i g n e d l o n g ) < / c o d e > 的 < c o d e > 取 值 范 围 < / c o d e > 。 < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : 定 义 和 打 印 长 整 型 变 量 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义有符号 long 类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > signed < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / l 1 = - 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义无符号 long 类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / l 2 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义 long 类型,默认是有符号</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > long < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / l 3 = - 2 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 获 取 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > u n s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d l o n g 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s i g n e d l o n g 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l o n g 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 获 取 类 型 的 取 值 范 围 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; l i m i t s . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d l o n g 类 型 的 范 围 是 [ 0 , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , U L O N G _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ 0 , 4 2 9 4 9 6 7 2 9 5 ] < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l o n g 类 型 的 范 围 是 [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , L O N G _ M I N , L O N G _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ - 2 1 4 7 4 8 3 6 4 8 , 2 1 4 7 4 8 3 6 4 7 ] < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 2 - 5 - 长 长 整 型 - 了 解 " t a b i n d e x = " - 1 " > 1 . 2 . 5 长 长 整 型 ( 了 解 ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 2 - 5 - 长 长 整 型 - 了 解 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 2 . 5 长 长 整 型 ( 了 解 ) & q u o t ; " > < / a > < / h 3 > < u l > < l i > 语 法 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > u n s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 无 符 号 长 长 整 型 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 有 符 号 长 长 整 型 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 有 符 号 表 示 的 是 正 数 、 负 数 和 0 , 即 有 正 负 号 。 无 符 号 表 示 的 是 0 和 正 数 , 即 正 整 数 , 没 有 符 号 。 < / l i > < l i > ② 在 < c o d e > p r i n t f < / c o d e > 中 < c o d e > 无 符 号 长 长 整 型 ( u n s i g n e d l o n g l o n g ) < / c o d e > 的 < c o d e > 格 式 占 位 符 < / c o d e > 是 < c o d e > % l l u < / c o d e > , < c o d e > 有 符 号 长 长 整 型 ( s i g n e d l o n g l o n g ) < / c o d e > 的 < c o d e > 格 式 占 位 符 < / c o d e > 是 < c o d e > % l l d < / c o d e > 。 < / l i > < l i > ③ 可 以 通 过 < c o d e > s i z e o f < / c o d e > 运 算 符 获 取 < c o d e > 无 符 号 长 长 整 型 ( u n s i g n e d l o n g l o n g ) < / c o d e > 和 < c o d e > 有 符 号 长 长 整 型 ( s i g n e d l o n g l o n g ) < / c o d e > 的 < c o d e > 存 储 空 间 ( 所 占 内 存 空 间 ) < / c o d e > 。 < / l i > < l i > ③ 可 以 通 过 < c o d e > # i n c l u d e & l t ; l i m i t s . h & g t ; < / c o d e > 来 获 取 < c o d e > 无 符 号 长 长 整 型 ( u n s i g n e d l o n g l o n g ) < / c o d e > 和 < c o d e > 有 符 号 长 长 整 型 ( s i g n e d l o n g l o n g ) < / c o d e > 的 < c o d e > 取 值 范 围 < / c o d e > 。 < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : 定 义 和 打 印 长 长 整 型 变 量 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义有符号 long long 类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > signed < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l l 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l l 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l l d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l l 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / l l 1 = - 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义无符号 long long 类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l l 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l l 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l l u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l l 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / l l 2 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 定义 long long 类型,默认是有符号</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > long < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l l 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l l 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l l d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l l 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / l l 3 = - 2 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 获 取 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l l 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > u n s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d l o n g l o n g 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l l 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 8 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l l 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; s i g n e d l o n g l o n g 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l l 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 8 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > l l 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l o n g l o n g 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , l l 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 8 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 获 取 类 型 的 取 值 范 围 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; l i m i t s . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d l o n g l o n g 类 型 的 范 围 是 [ 0 , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l l u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , U L L O N G _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ 0 , 1 8 4 4 6 7 4 4 0 7 3 7 0 9 5 5 1 6 1 5 ] < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l o n g l o n g 类 型 的 范 围 是 [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l l d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l l d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , L L O N G _ M I N , L L O N G _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ - 9 2 2 3 3 7 2 0 3 6 8 5 4 7 7 5 8 0 8 , 9 2 2 3 3 7 2 0 3 6 8 5 4 7 7 5 8 0 7 ] < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 2 - 6 - 字 面 量 后 缀 " t a b i n d e x = " - 1 " > 1 . 2 . 6 字 面 量 后 缀 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 2 - 6 - 字 面 量 后 缀 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 2 . 6 字 面 量 后 缀 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < c o d e > 字 面 量 < / c o d e > 是 < c o d e > 源 代 码 < / c o d e > 中 一 个 < c o d e > 固 定 值 < / c o d e > 的 < c o d e > 表 示 方 法 < / c o d e > , 用 于 直 接 表 示 数 据 , 即 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 0 0 就 是 字 面 量 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > L < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 0 0 L 就 是 字 面 量 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > L L < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 0 0 L L 就 是 字 面 量 < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 默 认 情 况 下 的 , 整 数 字 面 量 的 类 型 是 i n t 类 型 。 < / l i > < l i > ② 如 果 需 要 表 示 l o n g 类 型 的 字 面 量 , 需 要 添 加 后 缀 l 或 L , 建 议 L 。 < / l i > < l i > ③ 如 果 需 要 表 示 l o n g l o n g 类 型 的 字 面 量 , 需 要 添 加 后 缀 l l 或 L L , 建 议 L L 。 < / l i > < l i > ④ 如 果 需 要 表 示 无 符 号 整 数 类 型 的 字 面 量 , 需 要 添 加 u 或 U , 建 议 U 。 < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > <
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / n u m = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > long < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > L < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / n u m 2 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > long < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > L L < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l l d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / n u m 3 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 4 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > U < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m 4 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % u \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m 4 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / n u m 4 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 5 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > L U < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m 5 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l u \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m 5 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / n u m 5 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 6 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > U L L < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m 6 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l l u \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m 6 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / n u m 6 = 1 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 4 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 2 - 7 - 精 确 宽 度 类 型 " t a b i n d e x = " - 1 " > 1 . 2 . 7 精 确 宽 度 类 型 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 2 - 7 - 精 确 宽 度 类 型 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 2 . 7 精 确 宽 度 类 型 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 在 前 文 , 我 们 了 解 到 C 语 言 的 整 数 类 型 ( s h o r t 、 i n t 、 l o n g 、 l o n g l o n g ) 在 不 同 计 算 机 上 , 占 用 的 字 节 宽 度 可 能 不 一 样 。 但 是 , 有 的 时 候 , 我 们 希 望 整 数 类 型 的 存 储 空 间 ( 字 节 宽 度 ) 是 精 确 的 , 即 : 在 任 意 平 台 ( 计 算 机 ) 上 都 能 一 致 , 以 提 高 程 序 的 可 移 植 性 。 < / l i > < / u l > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > J a v a 语 言 中 的 数 据 类 型 的 存 储 空 间 ( 字 节 宽 度 ) 是 一 致 的 , 这 也 是 J a v a 语 言 能 够 跨 平 台 的 原 因 之 一 ( 最 主 要 的 原 因 还 是 J V M ) 。 < / l i > < l i > 在 嵌 入 式 开 发 中 , 使 用 精 确 宽 度 类 型 可 以 确 保 代 码 在 各 个 平 台 上 的 一 致 性 。 < / l i > < / u l > < / d i v > < u l > < l i > 在 C 语 言 的 标 准 头 文 件 < c o d e > & l t ; s t d i n t . h & g t ; < / c o d e > 中 定 义 了 一 些 新 的 类 型 别 名 , 如 下 所 示 : < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > 类 型 名 称 < / t h > < t h > 含 义 < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > i n t 8 _ t < / t d > < t d > 8 位 有 符 号 整 数 < / t d > < / t r > < t r > < t d > i n t 1 6 _ t < / t d > < t d > 1 6 位 有 符 号 整 数 < / t d > < / t r > < t r > < t d > i n t 3 2 _ t < / t d > < t d > 3 2 位 有 符 号 整 数 < / t d > < / t r > < t r > < t d > i n t 6 4 _ t < / t d > < t d > 6 4 位 有 符 号 整 数 < / t d > < / t r > < t r > < t d > u i n t 8 _ t < / t d > < t d > 8 位 无 符 号 整 数 < / t d > < / t r > < t r > < t d > u i n t 1 6 _ t < / t d > < t d > 1 6 位 无 符 号 整 数 < / t d > < / t r > < t r > < t d > u i n t 3 2 _ t < / t d > < t d > 3 2 位 无 符 号 整 数 < / t d > < / t r > < t r > < t d > u i n t 6 4 _ t < / t d > < t d > 6 4 位 无 符 号 整 数 < / t d > < / t r > < / t b o d y > < / t a b l e > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 上 面 的 这 些 类 型 都 是 类 型 别 名 , 编 译 器 会 指 定 它 们 指 向 的 底 层 类 型 , 如 : 在 某 个 系 统 中 , 如 果 i n t 类 型 是 3 2 位 , 那 么 i n t 3 2 _ t 就 会 指 向 i n t ; 如 果 l o n g 类 型 是 3 2 位 , 那 么 i n t 3 2 _ t 就 会 指 向 l o n g 。 < / p > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i n t . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 变量 x32 声明为 int32_t 类型,可以保证是 32 位(4个字节)的宽度。</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int32 _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x 3 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 4 5 9 3 3 9 4 5 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; x 3 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , x 3 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / x 3 2 = 4 5 9 3 3 9 4 5 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 2 - 8 - s i z e o f - 运 算 符 " t a b i n d e x = " - 1 " > 1 . 2 . 8 s i z e o f 运 算 符 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 2 - 8 - s i z e o f - 运 算 符 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 2 . 8 s i z e o f 运 算 符 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 语 法 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( 表 达 式 ) < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 表 达 式 可 以 是 任 何 类 型 的 数 据 类 型 、 变 量 或 常 量 。 < / l i > < l i > ② 返 回 某 种 数 据 类 型 或 某 个 值 占 用 的 字 节 数 量 , 并 且 < c o d e > s i z e o f ( . . . ) < / c o d e > 的 < c o d e > 返 回 值 类 型 < / c o d e > 是 < c o d e > s i z e _ t < / c o d e > 。 < / l i > < l i > ③ 在 < c o d e > p r i n t f < / c o d e > 中 使 用 占 位 符 < c o d e > % z u < / c o d e > 来 处 理 < c o d e > s i z e _ t < / c o d e > 类 型 的 值 。 < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : 参 数 是 数 据 类 型 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d d e f . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 参 数 是 变 量 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d d e f . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( n u m ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 参 数 是 常 量 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d d e f . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > size _t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 2 - 9 - 数 值 溢 出 " t a b i n d e x = " - 1 " > 1 . 2 . 9 数 值 溢 出 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 2 - 9 - 数 值 溢 出 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 2 . 9 数 值 溢 出 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 所 谓 的 数 值 溢 出 指 的 是 : 当 超 过 一 个 数 据 类 型 能 够 存 放 的 最 大 范 围 的 时 候 , 数 值 就 会 溢 出 。 < / p > < u l > < l i > 如 果 达 到 了 最 大 值 , 再 进 行 加 法 计 算 , 数 据 就 会 超 过 该 类 型 能 够 表 示 的 最 大 值 , 叫 做 上 溢 出 。 < / l i > < l i > 如 果 这 个 数 目 前 是 最 小 值 , 再 进 行 减 法 计 算 , 数 据 就 会 超 过 该 类 型 的 最 小 值 , 叫 做 下 溢 出 。 < / l i > < / u l > < / l i > < l i > < p > 在 C 语 言 中 , < c o d e > 整 数 < / c o d e > 的 < c o d e > 数 据 类 型 < / c o d e > 分 为 < c o d e > 无 符 号 < / c o d e > 和 < c o d e > 有 符 号 < / c o d e > 的 , 其 在 底 层 表 示 和 存 储 是 不 一 样 的 , 即 : < / p > < u l > < l i > < c o d e > 无 符 号 整 数 不 使 用 最 高 位 作 为 符 号 位 < / c o d e > , 所 有 的 位 都 用 于 表 示 数 值 , 如 : 对 于 一 个 4 位 无 符 号 整 数 , 二 进 制 表 示 的 范 围 是 从 0 0 0 0 到 1 1 1 1 , 那 么 十 进 制 表 示 的 范 围 是 从 0 到 1 5 。 < / l i > < l i > < c o d e > 有 符 号 整 数 使 用 最 高 位 作 为 符 号 位 < / c o d e > , 这 意 味 着 它 们 可 以 表 示 正 数 和 负 数 , 通 常 使 用 补 码 来 表 示 有 符 号 整 数 。 在 补 码 表 示 法 中 : 最 高 位 为 0 表 示 正 数 、 最 高 位 为 1 表 示 负 数 , 如 : 对 于 一 个 4 位 有 符 号 整 数 , 二 进 制 表 示 的 范 围 是 从 0 0 0 0 ( 0 ) 到 0 1 1 1 ( 7 ) , 1 0 0 0 ( - 8 ) 到 1 1 1 1 ( - 1 ) 。 < / l i > < / u l > < / l i > < / u l > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > 在 C 语 言 中 , 无 符 号 整 数 , 最 高 位 不 是 符 号 位 , 它 是 数 值 的 一 部 分 。 < / l i > < l i > 在 C 语 言 中 , 有 符 号 整 数 , 最 高 位 是 符 号 位 , 用 于 表 示 正 负 数 。 < / l i > < / u l > < / d i v > < u l > < l i > < p > 对 于 无 符 号 的 数 值 溢 出 : < / p > < u l > < l i > 当 数 据 到 达 最 大 值 的 时 候 , 再 加 1 就 会 回 到 无 符 号 数 的 最 小 值 。 < / l i > < l i > 当 数 据 达 到 最 小 值 的 时 候 , 再 减 1 就 会 回 到 无 符 号 数 的 最 大 值 。 < / l i > < / u l > < / l i > < l i > < p > 那 么 , 无 符 号 的 上 溢 出 , 原 理 就 是 这 样 的 : < / p > < / l i > < / u l > < p > < i m g s r c = " ` + t + ' " a l t = " " > < / p > < u l > < l i > 那 么 , 无 符 号 的 下 溢 出 , 原 理 就 是 这 样 的 ( 需 要 先 借 位 , 然 后 再 减 ) : < / l i > < / u l > < p > < i m g s r c = " ' + h + ' " a l t = " " > < / p > < u l > < l i > < p > 对 于 有 符 号 的 数 值 溢 出 : < / p > < u l > < l i > 当 数 据 到 达 最 大 值 的 时 候 , 再 加 1 就 会 回 到 有 符 号 数 的 最 小 值 。 < / l i > < l i > 当 数 据 达 到 最 小 值 的 时 候 , 再 减 1 就 会 回 到 有 符 号 数 的 最 大 值 。 < / l i > < / u l > < / l i > < l i > < p > 那 么 , 有 符 号 的 上 溢 出 , 原 理 就 是 这 样 的 : < / p > < / l i > < / u l > < p > < i m g s r c = " ' + k + ' " a l t = " " > < / p > < u l > < l i > 那 么 , 有 符 号 的 下 溢 出 , 原 理 就 是 这 样 的 : < / l i > < / u l > < p > < i m g s r c = " ' + e + ` " a l t = " " > < / p > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 在 实 际 开 发 中 , 选 择 合 适 的 数 据 类 型 , 以 避 免 数 值 溢 出 问 题 ! ! ! < / p > < / d i v > < u l > < l i > 示 例 : 无 符 号 的 上 溢 出 和 下 溢 出 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; l i m i t s . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s h o r t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > U S H R T _ M A X < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 无 符 号 的 上 溢 出 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s h o r t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 无 符 号 的 下 溢 出 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 6 5 5 3 5 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 有 符 号 的 上 溢 出 和 下 溢 出 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; l i m i t s . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > short < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > S H R T _ M A X < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 有 符 号 的 上 溢 出 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / - 3 2 7 6 8 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > short < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > S H R T _ M I N < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 有 符 号 的 下 溢 出 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % h d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 3 2 7 6 7 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 1 - 3 - 浮 点 类 型 " t a b i n d e x = " - 1 " > 1 . 3 浮 点 类 型 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 3 - 浮 点 类 型 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 3 浮 点 类 型 & q u o t ; " > < / a > < / h 2 > < h 3 i d = " _ 1 - 3 - 1 - 概 述 " t a b i n d e x = " - 1 " > 1 . 3 . 1 概 述 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 3 - 1 - 概 述 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 3 . 1 概 述 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 在 生 活 中 , 我 们 除 了 使 用 < c o d e > 整 数 < / c o d e > , 如 : 1 8 、 2 5 之 外 , 还 会 使 用 到 < c o d e > 小 数 < / c o d e > , 如 : 3 . 1 4 1 5 9 2 6 、 6 . 1 8 等 , < c o d e > 小 数 < / c o d e > 在 计 算 机 中 也 被 称 为 < c o d e > 浮 点 数 < / c o d e > ( 和 底 层 存 储 有 关 ) 。 < / l i > < l i > < c o d e > 整 数 < / c o d e > 在 计 算 机 底 层 的 存 储 被 称 为 < c o d e > 定 点 存 储 < / c o d e > , 如 下 所 示 : < / l i > < / u l > < p > < i m g s r c = " ` + r + ' " a l t = " " > < / p > < u l > < l i > < c o d e > 小 数 < / c o d e > 在 计 算 机 底 层 的 存 储 被 称 为 < c o d e > 浮 点 存 储 < / c o d e > , 如 下 所 示 : < / l i > < / u l > < p > < i m g s r c = " ' + d + ` " a l t = " " > < / p > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 计 算 机 底 层 就 是 采 取 类 似 科 学 计 数 法 的 形 式 来 存 储 小 数 的 , 而 科 学 技 术 法 的 表 现 就 是 这 样 的 , 如 : 3 . 1 2 * 1 0 ^ - 2 ; 其 中 , 1 0 是 基 数 , - 2 是 指 数 , 而 3 . 1 2 是 尾 数 。 < / l i > < l i > ② 因 为 尾 数 区 的 内 存 空 间 的 宽 度 不 同 , 导 致 了 小 数 的 精 度 也 不 相 同 , 所 以 小 数 在 计 算 机 中 也 称 为 浮 点 数 。 < / l i > < / u l > < / d i v > < u l > < l i > 在 C 语 言 中 , 变 量 的 浮 点 类 型 , 如 下 所 示 : < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > 类 型 < / t h > < t h > 存 储 大 小 < / t h > < t h > 值 的 范 围 < / t h > < t h > 有 效 小 数 位 数 < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > f l o a t ( 单 精 度 ) < / t d > < t d > 4 字 节 < / t d > < t d > 1 . 2 E - 3 8 ~ 3 . 4 E + 3 8 < / t d > < t d > 6 ~ 9 < / t d > < / t r > < t r > < t d > d o u b l e ( 双 精 度 ) < / t d > < t d > 8 字 节 < / t d > < t d > 2 . 3 E - 3 0 8 ~ 1 . 7 E + 3 0 8 < / t d > < t d > 1 5 ~ 1 8 < / t d > < / t r > < t r > < t d > l o n g d o u b l e ( 长 双 精 度 ) < / t d > < t d > 1 6 字 节 < / t d > < t d > 3 . 4 E - 4 9 3 2 ~ 1 . 2 E + 4 9 3 2 < / t d > < t d > 1 8 或 更 多 < / t d > < / t r > < / t b o d y > < / t a b l e > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 各 类 型 的 存 储 大 小 和 精 度 受 到 操 作 系 统 、 编 译 器 、 硬 件 平 台 的 影 响 。 < / l i > < l i > ② 浮 点 型 数 据 有 两 种 表 现 形 式 : < u l > < l i > 十 进 制 数 形 式 : 3 . 1 2 、 5 1 2 . 0 f 、 0 . 5 1 2 ( . 5 1 2 , 可 以 省 略 0 ) < / l i > < l i > 科 学 计 数 法 形 式 : 5 . 1 2 e 2 ( e 表 示 基 数 1 0 ) 、 5 . 1 2 E - 2 ( E 表 示 基 数 1 0 ) 。 < / l i > < / u l > < / l i > < l i > ③ 在 实 际 开 发 中 , 对 于 浮 点 类 型 , 建 议 使 用 d o u b l e 类 型 ; 如 果 范 围 不 够 , 就 使 用 l o n g d o u b l e 类 型 。 < / l i > < / u l > < / d i v > < h 3 i d = " _ 1 - 3 - 2 - 格 式 占 位 符 " t a b i n d e x = " - 1 " > 1 . 3 . 2 格 式 占 位 符 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 3 - 2 - 格 式 占 位 符 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 3 . 2 格 式 占 位 符 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 对 于 f l o a t 类 型 的 格 式 占 位 符 , 是 < c o d e > % f < / c o d e > , 默 认 会 保 留 < c o d e > 6 < / c o d e > 位 小 数 ; 可 以 指 定 小 数 位 , 如 : < c o d e > % . 2 f < / c o d e > 表 示 保 留 < c o d e > 2 < / c o d e > 位 小 数 。 < / p > < / l i > < l i > < p > 对 于 d o u b l e 类 型 的 格 式 占 位 符 , 是 < c o d e > % l f < / c o d e > , 默 认 会 保 留 < c o d e > 6 < / c o d e > 位 小 数 ; 可 以 指 定 小 数 位 , 如 : < c o d e > % . 2 l f < / c o d e > 表 示 保 留 < c o d e > 2 < / c o d e > 位 小 数 。 < / p > < / l i > < l i > < p > 对 于 l o n g d o u b l e 类 型 的 格 式 占 位 符 , 是 < c o d e > % L f < / c o d e > , 默 认 会 保 留 < c o d e > 6 < / c o d e > 位 小 数 ; 可 以 指 定 小 数 位 , 如 : < c o d e > % . 2 L f < / c o d e > 表 示 保 留 < c o d e > 2 < / c o d e > 位 小 数 。 < / p > < / l i > < l i > < p > 如 果 想 输 出 < c o d e > 科 学 计 数 法 < / c o d e > 形 式 的 浮 点 数 , 则 使 用 < c o d e > % e < / c o d e > 。 < / p > < / l i > < l i > < p > <EFBFBD>
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > float < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > f 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 . 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; f 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , f 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / f 1 = 1 0 . 0 0 0 0 0 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; f 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , f 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / f 1 = 1 0 . 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 3 . 1 4 1 5 9 2 6 5 3 5 4 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 1 = 1 3 . 1 4 1 5 9 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 l f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 1 = 1 3 . 1 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > long < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > d o u b l e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 3 . 1 4 1 5 9 2 6 5 3 5 4 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % L F < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 1 = 1 3 . 1 4 1 5 9 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 L F < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 1 = 1 3 . 1 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > float < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > f 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 . 1 4 1 5 9 2 6 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 . 1 4 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; f 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , f 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / f 1 = 3 . 1 4 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; f 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , f 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / f 1 = 3 . 1 4 e + 0 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 l f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 2 = 3 1 4 . 0 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 2 = 3 . 1 4 e + 0 2 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 3 - 3 - 字 面 量 后 缀 " t a b i n d e x = " - 1 " > 1 . 3 . 3 字 面 量 后 缀 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 3 - 3 - 字 面 量 后 缀 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 3 . 3 字 面 量 后 缀 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 浮 点 数 字 面 量 默 认 是 d o u b l e 类 型 。 < / p > < / l i > < l i > < p > 如 果 需 要 表 示 f l o a t 类 型 的 字 面 量 , 需 要 后 面 添 加 后 缀 f 或 F 。 < / p > < / l i > < l i > < p > 如 果 需 要 表 示 l o n g d o u b l e 类 型 的 字 面 量 , 需 要 后 面 添 加 后 缀 l 或 L 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > float < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > f 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 . 1 4 1 5 9 2 6 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 . 1 4 1 5 9 2 6 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > long < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > d o u b l e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 . 1 4 1 5 9 2 6 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > L < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; f 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , f 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / f 1 = 3 . 1 4 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 3 l f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 2 = 3 . 1 4 2 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 4 L f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 3 = 3 . 1 4 1 6 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 3 - 4 - 类 型 占 用 的 内 存 大 小 - 存 储 空 间 " t a b i n d e x = " - 1 " > 1 . 3 . 4 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 3 - 4 - 类 型 占 用 的 内 存 大 小 - 存 储 空 间 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 3 . 4 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 可 以 通 过 s i z e o f 运 算 符 来 获 取 f l o a t 、 d o u b l e 以 及 l o n g d o u b l e 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; f l o a t 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > f l o a t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 4 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d o u b l e 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > d o u b l e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 8 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; l o n g d o u b l e 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % z u < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > l o n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > d o u b l e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 6 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 3 - 5 - 类 型 的 取 值 范 围 " t a b i n d e x = " - 1 " > 1 . 3 . 5 类 型 的 取 值 范 围 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 3 - 5 - 类 型 的 取 值 范 围 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 3 . 5 类 型 的 取 值 范 围 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 可 以 通 过 < c o d e > # i n c l u d e & l t ; f l o a t . h & g t ; < / c o d e > 来 获 取 类 型 的 取 值 范 围 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; f l o a t . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; f l o a t 的 取 值 范 围 是 : [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 3 8 f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , F L T _ M I N , F L T _ M A X ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d o u b l e 的 取 值 范 围 是 : [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % l f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , D B L _ M I N , D B L _ M A X ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d o u b l e 的 取 值 范 围 是 : [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % L f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % L f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , L D B L _ M I N , L D B L _ M A X ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 1 - 4 - 字 符 类 型 " t a b i n d e x = " - 1 " > 1 . 4 字 符 类 型 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 4 - 字 符 类 型 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 4 字 符 类 型 & q u o t ; " > < / a > < / h 2 > < h 3 i d = " _ 1 - 4 - 1 - 概 述 " t a b i n d e x = " - 1 " > 1 . 4 . 1 概 述 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 4 - 1 - 概 述 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 4 . 1 概 述 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 在 生 活 中 , 我 们 会 经 常 说 : 今 天 天 气 真 < c o d e > 好 < / c o d e > , 我 的 性 别 是 < c o d e > 女 < / c o d e > , 我 今 年 < c o d e > 1 0 < / c o d e > 岁 , 像 这 类 数 据 , 在 C 语 言 中 就 可 以 用 字 符 ( c h a r ) 来 表 示 。 < / l i > < l i > 在 C 语 言 中 , 变 量 的 < c o d e > 字 符 类 型 < / c o d e > 可 以 表 示 < c o d e > 单 < / c o d e > 个 字 符 , 如 : < c o d e > & # 3 9 ; 1 & # 3 9 ; < / c o d e > 、 < c o d e > & # 3 9 ; A & # 3 9 ; < / c o d e > 、 < c o d e > & # 3 9 ; & a m p ; & # 3 9 ; < / c o d e > 。 < / l i > < / u l > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > C 语 言 的 出 现 在 1 9 7 2 年 , 由 美 国 人 丹 尼 斯 · 里 奇 设 计 出 来 ; 那 个 时 候 , 只 需 要 1 个 字 节 的 内 存 空 间 , 就 可 以 完 美 的 表 示 拉 丁 体 系 ( 英 文 ) 文 字 , 如 : a - z 、 A - Z 、 0 - 9 以 及 一 些 特 殊 符 号 ; 所 以 , C 语 言 中 不 支 持 多 个 字 节 的 字 符 , 如 : 中 文 、 日 文 等 。 < / l i > < l i > C 语 言 中 没 有 字 符 串 类 型 , 是 使 用 字 符 数 组 ( c h a r 数 组 ) 来 模 拟 字 符 串 的 , 并 且 字 符 数 组 也 不 是 字 符 串 , 而 是 构 造 类 型 。 < / l i > < l i > 在 C 语 言 中 , 如 果 想 要 输 出 中 文 、 日 文 等 多 字 节 字 符 , 就 需 要 使 用 字 符 数 组 ( c h a r 数 组 ) 。 < / l i > < l i > 在 C + + 、 J a v a 等 高 级 编 程 语 言 中 , 已 经 提 供 了 S t r i n g ( 字 符 串 ) 类 型 , 原 生 支 持 U n i c o d e , 可 以 方 便 地 处 理 多 语 言 和 特 殊 字 符 。 < / l i > < / u l > < / d i v > < u l > < l i > 在 C 语 言 中 , 可 以 使 用 < c o d e > 转 义 字 符 \ \ < / c o d e > 来 表 示 特 殊 含 义 的 字 符 。 < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > < s t r o n g > 转 义 字 符 < / s t r o n g > < / t h > < t h > < s t r o n g > 说 明 < / s t r o n g > < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > < c o d e > \ \ b < / c o d e > < / t d > < t d > 退 格 < / t d > < / t r > < t r > < t d > < c o d e > \ \ n < / c o d e > < / t d > < t d > 换 行 符 < / t d > < / t r > < t r > < t d > < c o d e > \ \ r < / c o d e > < / t d > < t d > 回 车 符 < / t d > < / t r > < t r > < t d > < c o d e > \ \ t < / c o d e > < / t d > < t d > 制 表 符 < / t d > < / t r > < t r > < t d > < c o d e > \ \ & q u o t ; < / c o d e > < / t d > < t d > 双 引 号 < / t d > < / t r > < t r > < t d > < c o d e > \ \ & # 3 9 ; < / c o d e > < / t d > < t d > 单 引 号 < / t d > < / t r > < t r > < t d > < c o d e > \ \ \ \ < / c o d e > < / t d > < t d > 反 斜 杠 < / t d > < / t r > < t r > < t d > . . . < / t d > < t d > < / t d > < / t r > < / t b o d y > < / t a b l e > < h 3 i d = " _ 1 - 4 - 2 - 格 式 占 位 符 " t a b i n d e x = " - 1 " > 1 . 4 . 2 格 式 占 位 符 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 4 - 2 - 格 式 占 位 符 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 4 . 2 格 式 占 位 符 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 在 C 语 言 中 , 使 用 < c o d e > % c < / c o d e > 来 表 示 c h a r 类 型 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; & a m p ; & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; c = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , c ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / c = & a m p ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > c 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; a & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; c 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , c 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / c 2 = a < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > c 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; A & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; c 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , c 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / c 3 = A < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 4 - 3 - 类 型 占 用 的 内 存 大 小 - 存 储 空 间 " t a b i n d e x = " - 1 " > 1 . 4 . 3 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 4 - 3 - 类 型 占 用 的 内 存 大 小 - 存 储 空 间 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 4 . 3 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 可 以 通 过 s i z e o f 运 算 符 来 获 取 c h a r 类 型 占 用 的 内 存 大 小 ( 存 储 空 间 ) 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; c h a r 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > c h a r < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d c h a r 的 存 储 空 间 是 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 字 节 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > u n s i g n e d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > c h a r < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 4 - 4 - 类 型 的 取 值 范 围 " t a b i n d e x = " - 1 " > 1 . 4 . 4 类 型 的 取 值 范 围 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 4 - 4 - 类 型 的 取 值 范 围 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 4 . 4 类 型 的 取 值 范 围 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 可 以 通 过 < c o d e > # i n c l u d e & l t ; l i m i t s . h & g t ; < / c o d e > 来 获 取 类 型 的 取 值 范 围 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; l i m i t s . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; c h a r 范 围 是 [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , C H A R _ M I N , C H A R _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ - 1 2 8 , 1 2 7 ] < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; u n s i g n e d c h a r 范 围 是 [ 0 , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , U C H A R _ M A X ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / [ 0 , 2 5 5 ] < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
2024-07-23 03:25:31 +02:00
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 4 - 5 - 字 符 类 型 的 本 质 " t a b i n d e x = " - 1 " > 1 . 4 . 5 字 符 类 型 的 本 质 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 4 - 5 - 字 符 类 型 的 本 质 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 4 . 5 字 符 类 型 的 本 质 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 在 C 语 言 中 , c h a r 本 质 上 就 是 一 个 整 数 , 是 A S C I I 码 中 对 应 的 数 字 , 占 用 的 内 存 大 小 是 1 个 字 节 ( 存 储 空 间 ) , 所 以 c h a r 类 型 也 可 以 进 行 数 学 运 算 。 < / l i > < / u l > < p > < i m g s r c = " ` + E + ' " a l t = " " > < / p > < u l > < l i > c h a r 类 型 同 样 分 为 s i g n e d c h a r ( 无 符 号 ) 和 u n s i g n e d c h a r ( 有 符 号 ) , 其 中 s i g n e d c h a r 取 值 范 围 - 1 2 8 ~ 1 2 7 , u n s i g n e d c h a r 取 值 范 围 0 ~ 2 5 5 , 默 认 是 否 带 符 号 取 决 于 当 前 运 行 环 境 。 < / l i > < l i > < c o d e > 字 符 类 型 的 数 据 < / c o d e > 在 计 算 机 中 < c o d e > 存 储 < / c o d e > 和 < c o d e > 读 取 < / c o d e > 的 过 程 , 如 下 所 示 : < / l i > < / u l > < p > < i m g s r c = " ' + c + ` " a l t = " " > < / p > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; l i m i t s . h & g t ; < / s p a n > < / s p a n >
2024-07-19 09:46:50 +02:00
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # include < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // char 类型字面量需要使用单引号包裹</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; A & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; 9 & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; c 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , c 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , c 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a 1 , a 3 , a 2 ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // char 类型本质上整数可以进行运算</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; b & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > - & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , b 1 , b 1 ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > - & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , b 2 , b 2 ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , b 1 , b 2 , b 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b 2 ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // char 类型取值范围</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > c h a r < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > c 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 无 符 号 c h a r 取 值 范 围 0 ~ 2 5 5 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > signed < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > c h a r < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > c 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 有 符 号 c h a r 取 值 范 围 - 1 2 8 ~ 1 2 7 , c 2 会 超 出 范 围 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > c 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 当 前 系 统 , c h a r 默 认 是 s i g n e d c h a r < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; c 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , c 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , c 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , c 1 , c 2 , c 3 ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 5 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 1 - 5 - 布 尔 类 型 " t a b i n d e x = " - 1 " > 1 . 5 布 尔 类 型 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 5 - 布 尔 类 型 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 5 布 尔 类 型 & q u o t ; " > < / a > < / h 2 > < h 3 i d = " _ 1 - 5 - 1 - 概 述 " t a b i n d e x = " - 1 " > 1 . 5 . 1 概 述 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 5 - 1 - 概 述 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 5 . 1 概 述 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 布 尔 值 用 于 表 示 t r u e ( 真 ) 、 f a l s e ( 假 ) 两 种 状 态 , 通 常 用 于 逻 辑 运 算 和 条 件 判 断 。 < / l i > < / u l > < h 3 i d = " _ 1 - 5 - 2 - 早 期 的 布 尔 类 型 " t a b i n d e x = " - 1 " > 1 . 5 . 2 早 期 的 布 尔 类 型 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 5 - 2 - 早 期 的 布 尔 类 型 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 5 . 2 早 期 的 布 尔 类 型 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 在 C 语 言 标 准 ( C 8 9 ) 中 , 并 没 有 为 布 尔 值 单 独 设 置 一 个 数 据 类 型 , 所 以 在 判 断 真 、 假 的 时 候 , 使 用 < c o d e > 0 < / c o d e > 表 示 < c o d e > f a l s e < / c o d e > ( 假 ) , < c o d e > 非 0 < / c o d e > 表 示 < c o d e > t r u e < / c o d e > ( 真 ) 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 使用整型来表示真和假两种状态</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > h a n d s o m e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 帅 不 帅 [ 0 丑 , 1 帅 ] : & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > scanf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & a m p ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > h a n d s o m e ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > if < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( h a n d s o m e ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 你 真 的 很 帅 ! ! ! & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 你 真 的 很 丑 ! ! ! & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 5 - 3 - 宏 定 义 的 布 尔 类 型 " t a b i n d e x = " - 1 " > 1 . 5 . 3 宏 定 义 的 布 尔 类 型 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 5 - 3 - 宏 定 义 的 布 尔 类 型 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 5 . 3 宏 定 义 的 布 尔 类 型 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 判 断 真 假 的 时 候 , 以 < c o d e > 0 < / c o d e > 为 < c o d e > f a l s e < / c o d e > ( 假 ) 、 < c o d e > 1 < / c o d e > 为 < c o d e > t r u e < / c o d e > ( 真 ) , 并 不 直 观 ; 所 以 , 我 们 可 以 借 助 C 语 言 的 宏 定 义 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 宏定义</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # define < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > B O O L < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # define < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > T R U E < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > # define < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > F A L S E < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > BOOL handsome < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 帅 不 帅 [ F A L S E 丑 , T R U E 帅 ] : & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > scanf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & a m p ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > h a n d s o m e ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > if < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( h a n d s o m e ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 你 真 的 很 帅 ! ! ! & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 你 真 的 很 丑 ! ! ! & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 1 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 5 - 4 - c 9 9 - 标 准 中 的 布 尔 类 型 " t a b i n d e x = " - 1 " > 1 . 5 . 4 C 9 9 标 准 中 的 布 尔 类 型 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 5 - 4 - c 9 9 - 标 准 中 的 布 尔 类 型 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 5 . 4 C 9 9 标 准 中 的 布 尔 类 型 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 在 C 9 9 中 提 供 了 < c o d e > _ B o o l < / c o d e > 关 键 字 , 用 于 表 示 布 尔 类 型 ; 其 实 , < c o d e > _ B o o l < / c o d e > 类 型 的 值 是 整 数 类 型 的 别 名 , 和 一 般 整 型 不 同 的 是 , < c o d e > _ B o o l < / c o d e > 类 型 的 值 只 能 赋 值 为 < c o d e > 0 < / c o d e > 或 < c o d e > 1 < / c o d e > ( 0 表 示 假 、 1 表 示 真 ) , 其 它 < c o d e > 非 0 < / c o d e > 的 值 都 会 被 存 储 为 < c o d e > 1 < / c o d e > 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > _Bool < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > h a n d s o m e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 帅 不 帅 [ 0 丑 , 1 帅 ] : & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > scanf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & a m p ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > h a n d s o m e ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > if < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( h a n d s o m e ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 你 真 的 很 帅 ! ! ! & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 你 真 的 很 丑 ! ! ! & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 5 - 5 - c 9 9 - 标 准 头 文 件 中 的 布 尔 类 型 - 推 荐 " t a b i n d e x = " - 1 " > 1 . 5 . 5 C 9 9 标 准 头 文 件 中 的 布 尔 类 型 ( 推 荐 ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 5 - 5 - c 9 9 - 标 准 头 文 件 中 的 布 尔 类 型 - 推 荐 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 5 . 5 C 9 9 标 准 头 文 件 中 的 布 尔 类 型 ( 推 荐 ) & q u o t ; " > < / a > < / h 3 > < u l > < l i > 在 C 9 9 中 提 供 了 一 个 头 文 件 < c o d e > & l t ; s t d b o o l . h & g t ; < / c o d e > , 定 义 了 < c o d e > b o o l < / c o d e > 代 表 < c o d e > _ B o o l < / c o d e > , < c o d e > f a l s e < / c o d e > 代 表 < c o d e > 0 < / c o d e > , < c o d e > t r u e < / c o d e > 代 表 < c o d e > 1 < / c o d e > 。 < / l i > < / u l > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 在 C + + 、 J a v a 等 高 级 编 程 语 言 中 是 有 b o o l e a n 类 型 的 关 键 字 的 。 < / p > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > bool < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > h a n d s o m e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > f a l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 帅 不 帅 [ f a l s e 丑 , t r u e 帅 ] : & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > scanf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & a m p ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > h a n d s o m e ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > if < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( h a n d s o m e ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 你 真 的 很 帅 ! ! ! & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 你 真 的 很 丑 ! ! ! & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 1 - 6 - 数 据 类 型 转 换 " t a b i n d e x = " - 1 " > 1 . 6 数 据 类 型 转 换 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 6 - 数 据 类 型 转 换 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 6 数 据 类 型 转 换 & q u o t ; " > < / a > < / h 2 > < h 3 i d = " _ 1 - 6 - 1 - 概 述 " t a b i n d e x = " - 1 " > 1 . 6 . 1 概 述 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 6 - 1 - 概 述 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 6 . 1 概 述 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 在 C 语 言 编 程 中 , 经 常 需 要 对 不 同 类 型 的 数 据 进 行 运 算 , 运 算 前 需 要 先 转 换 为 同 一 类 型 , 再 运 算 。 为 了 解 决 数 据 类 型 不 一 致 的 问 题 , 需 要 对 数 据 的 类 型 进 行 转 换 。 < / l i > < / u l > < h 3 i d = " _ 1 - 6 - 2 - 自 动 类 型 转 换 - 隐 式 转 换 " t a b i n d e x = " - 1 " > 1 . 6 . 2 自 动 类 型 转 换 ( 隐 式 转 换 ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 6 - 2 - 自 动 类 型 转 换 - 隐 式 转 换 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 6 . 2 自 动 类 型 转 换 ( 隐 式 转 换 ) & q u o t ; " > < / a > < / h 3 > < h 4 i d = " _ 1 - 6 - 2 - 1 - 运 算 过 程 中 的 自 动 类 型 转 换 " t a b i n d e x = " - 1 " > 1 . 6 . 2 . 1 运 算 过 程 中 的 自 动 类 型 转 换 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 6 - 2 - 1 - 运 算 过 程 中 的 自 动 类 型 转 换 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 6 . 2 . 1 运 算 过 程 中 的 自 动 类 型 转 换 & q u o t ; " > < / a > < / h 4 > < u l > < l i > 不 同 类 型 的 数 据 进 行 混 合 运 算 的 时 候 , 会 发 生 数 据 类 型 转 换 , < c o d e > 窄 类 型 会 自 动 转 换 为 宽 类 型 < / c o d e > , 这 样 就 不 会 造 成 精 度 损 失 。 < / l i > < / u l > < p > < i m g s r c = " ` + g + ' " a l t = " " > < / p > < u l > < l i > 转 换 规 则 : < u l > < l i > ① 不 同 类 型 的 整 数 进 行 运 算 的 时 候 , 窄 类 型 整 数 会 自 动 转 换 为 宽 类 型 整 数 。 < / l i > < l i > ② 不 同 类 型 的 浮 点 数 进 行 运 算 的 时 候 , 精 度 小 的 类 型 会 自 动 转 换 为 精 度 大 的 类 型 。 < / l i > < l i > ③ 整 数 和 浮 点 数 进 行 运 算 的 时 候 , 整 数 会 自 动 转 换 为 浮 点 数 。 < / l i > < / u l > < / l i > < l i > 转 换 方 向 : < / l i > < / u l > < p > < i m g s r c = " ' + F + ` " a l t = " " > < / p > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 最 好 避 免 无 符 号 整 数 与 有 符 号 整 数 的 混 合 运 算 , 因 为 这 时 C 语 言 会 自 动 将 s i g n e d i n t 转 为 u n s i g n e d i n t , 可 能 不 会 得 到 预 期 的 结 果 。 < / p > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > / * * < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * 不同的整数类型混合运算时 , 宽度较小的类型会提升为宽度较大的类型 , 比如 short 转为 int , int 转为 long 等 。 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * / < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > short < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // s1 是 short 类型, i 是 int 类型,当 s1 和 i 运算的时候,会自动转为 int 类型后,然后再计算。</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s u l t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; r e s u l t = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s u l t ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > unsigned < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // n2 是有符号, n3 是无符号,当 n2 和 n3 运算的时候,会自动转为无符号类型后,然后再计算。</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s u l t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n 3 ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; r e s u l t = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s u l t ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > / * * < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * 不同的浮点数类型混合运算时 , 宽度较小的类型转为宽度较大的类型 , 比如 float 转为 double , double 转为 long double 。 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * / < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > float < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > f 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 . 2 5 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 4 . 5 8 6 6 7 4 3 5 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // f1 是 float 类型, d2 是 double 类型,当 f1 和 d2 运算的时候,会自动转为 double 类型后,然后再计算。</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s u l t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > f 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 2 ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; r e s u l t = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 8 l f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s u l t ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > / * * < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * 整型与浮点型运算 , 整型转为浮点型 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * / < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n 4 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 . 6 7 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // n4 是 int 类型, d3 是 double 类型,当 n4 和 d3 运算的时候,会自动转为 double 类型后,然后再计算。</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s u l t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n 4 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 3 ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 l f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s u l t ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < / d i v > < / d i v > < h 4 i d = " _ 1 - 6 - 2 - 2 - 赋 值 时 的 自 动 类 型 转 换 " t a b i n d e x = " - 1 " > 1 . 6 . 2 . 2 赋 值 时 的 自 动 类 型 转 换 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 6 - 2 - 2 - 赋 值 时 的 自 动 类 型 转 换 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 6 . 2 . 2 赋 值 时 的 自 动 类 型 转 换 & q u o t ; " > < / a > < / h 4 > < u l > < l i > 在 赋 值 运 算 中 , 赋 值 号 两 边 量 的 数 据 类 型 不 同 时 , 等 号 右 边 的 类 型 将 转 换 为 左 边 的 类 型 。 < / l i > < l i > 如 果 窄 类 型 赋 值 给 宽 类 型 , 不 会 造 成 精 度 损 失 ; 如 果 宽 类 型 赋 值 给 窄 类 型 , 会 造 成 精 度 损 失 。 < / l i > < / u l > < p > < i m g s r c = " ` + y + ` " a l t = " " > < / p > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > C 语 言 在 检 查 类 型 匹 配 方 面 不 太 严 格 , 最 好 不 要 养 成 这 样 的 习 惯 。 < / p > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 赋值:窄类型赋值给宽类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a 1 ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; a 2 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % . 2 f \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a 2 : 1 0 . 0 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 转换:将宽类型转换为窄类型</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 . 5 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b 1 ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; b 2 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , b 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / b 2 : 1 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
2024-07-19 09:53:33 +02:00
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 1 - 6 - 3 - 强 制 类 型 转 换 " t a b i n d e x = " - 1 " > 1 . 6 . 3 强 制 类 型 转 换 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 1 - 6 - 3 - 强 制 类 型 转 换 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 1 . 6 . 3 强 制 类 型 转 换 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 隐 式 类 型 转 换 中 的 宽 类 型 赋 值 给 窄 类 型 , 编 译 器 是 会 产 生 警 告 的 , 提 示 程 序 存 在 潜 在 的 隐 患 , 如 果 非 常 明 确 地 希 望 转 换 数 据 类 型 , 就 需 要 用 到 强 制 ( 或 显 式 ) 类 型 转 换 。 < / l i > < l i > 语 法 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > 数 据 类 型 变 量 名 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( 类 型 名 ) 变 量 、 常 量 或 表 达 式 ; < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < / d i v > < / d i v > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 强 制 类 型 转 换 可 能 会 导 致 精 度 损 失 ! ! ! < / p > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
2024-07-19 09:46:50 +02:00
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 . 9 3 4 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > double < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 4 . 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) d 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) d 2 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 1 转 为 1 , d 2 转 为 4 , 结 果 是 5 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ( d 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d 1 + d 2 = 6 . 1 3 4 , 6 . 1 3 4 转 为 6 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 . 5 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > * < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 6 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > * < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 . 5 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 3 5 . 0 + 9 . 0 = 4 4 . 0 - & g t ; i n t = 4 4 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m 1 ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m 2 ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; n u m 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , n u m 3 ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < / d i v > < / d i v > < h 1 i d = " 第 二 章 - 运 算 符 - ⭐ " t a b i n d e x = " - 1 " > 第 二 章 : 运 算 符 ( ⭐ ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # 第 二 章 - 运 算 符 - ⭐ " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 第 二 章 : 运 算 符 ( ⭐ ) & q u o t ; " > < / a > < / h 1 > < h 2 i d = " _ 2 - 1 - 概 述 " t a b i n d e x = " - 1 " > 2 . 1 概 述 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 1 - 概 述 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 1 概 述 & q u o t ; " > < / a > < / h 2 > < u l > < l i > 运 算 符 是 一 种 特 殊 的 符 号 , 用 于 数 据 的 运 算 、 赋 值 和 比 较 等 。 < / l i > < l i > < c o d e > 表 达 式 < / c o d e > 指 的 是 一 组 运 算 数 、 运 算 符 的 组 合 , 表 达 式 < c o d e > 一 定 具 有 值 < / c o d e > , 一 个 变 量 或 一 个 常 量 可 以 是 表 达 式 , 变 量 、 常 量 和 运 算 符 也 可 以 组 成 表 达 式 , 如 : < / l i > < / u l > < p > < i m g s r c = " ` + u + ' " a l t = " " > < / p > < u l > < l i > < c o d e > 操 作 数 < / c o d e > 指 的 是 < c o d e > 参 与 运 算 < / c o d e > 的 < c o d e > 值 < / c o d e > 或 者 < c o d e > 对 象 < / c o d e > , 如 : < / l i > < / u l > < p > < i m g s r c = " ' + b + ` " a l t = " " > < / p > < u l > < l i > 根 据 < c o d e > 操 作 数 < / c o d e > 的 < c o d e > 个 数 < / c o d e > , 可 以 将 运 算 符 分 为 : < u l > < l i > 一 元 运 算 符 ( 一 目 运 算 符 ) 。 < / l i > < l i > 二 元 运 算 符 ( 二 目 运 算 符 ) 。 < / l i > < l i > 三 元 运 算 符 ( 三 目 运 算 符 ) 。 < / l i > < / u l > < / l i > < l i > 根 据 < c o d e > 功 能 < / c o d e > , 可 以 将 运 算 符 分 为 : < u l > < l i > 算 术 运 算 符 。 < / l i > < l i > 关 系 运 算 符 ( 比 较 运 算 符 ) 。 < / l i > < l i > 逻 辑 运 算 符 。 < / l i > < l i > 赋 值 运 算 符 。 < / l i > < l i > 逻 辑 运 算 符 。 < / l i > < l i > 位 运 算 符 。 < / l i > < l i > 三 元 运 算 符 。 < / l i > < / u l > < / l i > < / u l > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 掌 握 一 个 运 算 符 , 需 要 关 注 以 下 几 个 方 面 : < / p > < u l > < l i > ① 运 算 符 的 含 义 。 < / l i > < l i > ② 运 算 符 操 作 数 的 个 数 。 < / l i > < l i > ③ 运 算 符 所 组 成 的 表 达 式 。 < / l i > < l i > ④ 运 算 符 有 无 副 作 用 , 即 : 运 算 后 是 否 会 修 改 操 作 数 的 值 。 < / l i > < / u l > < / d i v > < h 2 i d = " _ 2 - 2 - 算 术 运 算 符 " t a b i n d e x = " - 1 " > 2 . 2 算 术 运 算 符 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 2 - 算 术 运 算 符 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 2 算 术 运 算 符 & q u o t ; " > < / a > < / h 2 > < u l > < l i > 算 术 运 算 符 是 对 数 值 类 型 的 变 量 进 行 运 算 的 , 如 下 所 示 : < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > 运 算 符 < / t h > < t h > 描 述 < / t h > < t h > 操 作 数 个 数 < / t h > < t h > 组 成 的 表 达 式 的 值 < / t h > < t h > 副 作 用 < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > < c o d e > + < / c o d e > < / t d > < t d > 正 号 < / t d > < t d > 1 < / t d > < t d > 操 作 数 本 身 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > - < / c o d e > < / t d > < t d > 负 号 < / t d > < t d > 1 < / t d > < t d > 操 作 数 符 号 取 反 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > + < / c o d e > < / t d > < t d > 加 号 < / t d > < t d > 2 < / t d > < t d > 两 个 操 作 数 之 和 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > - < / c o d e > < / t d > < t d > 减 号 < / t d > < t d > 2 < / t d > < t d > 两 个 操 作 数 之 差 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > * < / c o d e > < / t d > < t d > 乘 号 < / t d > < t d > 2 < / t d > < t d > 两 个 操 作 数 之 积 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > / < / c o d e > < / t d > < t d > 除 号 < / t d > < t d > 2 < / t d > < t d > 两 个 操 作 数 之 商 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > % < / c o d e > < / t d > < t d > 取 模 ( 取 余 ) < / t d > < t d > 2 < / t d > < t d > 两 个 操 作 数 相 除 的 余 数 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > + + < / c o d e > < / t d > < t d > 自 增 < / t d > < t d > 1 < / t d > < t d > 操 作 数 自 增 前 或 自 增 后 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > - - < / c o d e > < / t d > < t d > 自 减 < / t d > < t d > 1 < / t d > < t d > 操 作 数 自 减 前 或 自 减 后 的 值 < / t d > < t d > ✅ < / t d > < / t r > < / t b o d y > < / t a b l e > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 自 增 和 自 减 : < / p > < u l > < l i > ① 自 增 、 自 减 运 算 符 可 以 写 <EFBFBD>
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x , x 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > x ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > y < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 6 7 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > y 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > y , y 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > y ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; x 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , x 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , x 1 , x 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / x 1 = - 1 2 , x 2 = 1 2 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; y 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > , y 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , y 1 , y 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / y 1 = 6 7 , y 2 = - 6 7 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 加 、 减 、 乘 、 除 ( 整 数 之 间 做 除 法 时 , 结 果 只 保 留 整 数 部 分 而 舍 弃 小 数 部 分 ) 、 取 模 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 5 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , b , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 5 + 2 = 7 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , b , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 5 - 2 = 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > × < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , b , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > * < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 5 × 2 = 1 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > / < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , b , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > / < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 5 / 2 = 2 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , b , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 5 % 2 = 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 取 模 ( 运 算 结 果 的 符 号 与 被 模 数 也 就 是 第 一 个 操 作 数 相 同 。 ) < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 0 % 3 = 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; - 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / - 1 0 % 3 = - 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > - 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s 3 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 0 % - 3 = 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s 4 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; - 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > - 3 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s 4 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / - 1 0 % - 3 = - 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : 自 增 和 自 减 < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i = 1 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i 1 = 1 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 1 ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i = 1 2 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i 1 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 1 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i 1 = 1 2 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i = 2 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i 2 = 1 9 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i 2 ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i = 1 8 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; i 2 = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , i 2 ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / i 2 = 1 8 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 2 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > / * < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 随意给出一个整数 , 打印显示它的个位数 , 十位数 , 百位数的值 。 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 格式如下 : < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 数字xxx的情况如下 : < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 个位数 : < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 十位数 : < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 百位数 : < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 例如 : < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 数字153的情况如下 : < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 个位数 : 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 十位数 : 5 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > 百位数 : 1 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * / < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 5 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b a i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > / < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > s h i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > / < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > g e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > % < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 百 位 为 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , b a i ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 十 位 为 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , s h i ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 个 位 为 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , g e ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 8 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 2 - 3 - 关 系 运 算 符 - 比 较 运 算 符 " t a b i n d e x = " - 1 " > 2 . 3 关 系 运 算 符 ( 比 较 运 算 符 ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 3 - 关 系 运 算 符 - 比 较 运 算 符 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 3 关 系 运 算 符 ( 比 较 运 算 符 ) & q u o t ; " > < / a > < / h 2 > < u l > < l i > 常 见 的 关 系 运 算 符 , 如 下 所 示 : < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > 运 算 符 < / t h > < t h > 描 述 < / t h > < t h > 操 作 数 个 数 < / t h > < t h > 组 成 的 表 达 式 的 值 < / t h > < t h > 副 作 用 < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > < c o d e > = = < / c o d e > < / t d > < t d > 相 等 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > ! = < / c o d e > < / t d > < t d > 不 相 等 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > & l t ; < / c o d e > < / t d > < t d > 小 于 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > & g t ; < / c o d e > < / t d > < t d > 大 于 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > & l t ; = < / c o d e > < / t d > < t d > 小 于 等 于 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > & g t ; = < / c o d e > < / t d > < t d > 大 于 等 于 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < / t b o d y > < / t a b l e > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① C 语 言 中 , 没 有 严 格 意 义 上 的 布 尔 类 型 , 所 以 可 以 0 ( 假 ) 或 1 ( 真 ) 表 示 布 尔 类 型 的 值 。 < / l i > < l i > ② 不 要 将 < c o d e > = = < / c o d e > 写 成 < c o d e > = < / c o d e > , < c o d e > = = < / c o d e > 是 比 较 运 算 符 , 而 < c o d e > = < / c o d e > 是 赋 值 运 算 符 。 < / l i > < l i > ③ < c o d e > & g t ; = < / c o d e > 或 < c o d e > & l t ; = < / c o d e > 含 义 是 只 需 要 满 足 < c o d e > 大 于 或 等 于 < / c o d e > 、 < c o d e > 小 于 或 等 于 < / c o d e > 其 中 一 个 条 件 , 结 果 就 返 回 真 。 < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 8 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 7 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; a & g t ; b 的 结 果 是 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a & g t ; b 的 结 果 是 : 1 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; a & g t ; = b 的 结 果 是 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & g t ; = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a & g t ; = b 的 结 果 是 : 1 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; a & l t ; b 的 结 果 是 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & l t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a & l t ; b 的 结 果 是 : 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; a & l t ; = b 的 结 果 是 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & l t ; = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a & l t ; = b 的 结 果 是 : 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; a = = b 的 结 果 是 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a = = b 的 结 果 是 : 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; a ! = b 的 结 果 是 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > ! = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a ! = b 的 结 果 是 : 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
2024-07-19 09:59:59 +02:00
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 2 - 4 - 逻 辑 运 算 符 " t a b i n d e x = " - 1 " > 2 . 4 逻 辑 运 算 符 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 4 - 逻 辑 运 算 符 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 4 逻 辑 运 算 符 & q u o t ; " > < / a > < / h 2 > < u l > < l i > 常 见 的 逻 辑 运 算 符 , 如 下 所 示 : < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > 运 算 符 < / t h > < t h > 描 述 < / t h > < t h > 操 作 数 个 数 < / t h > < t h > 组 成 的 表 达 式 的 值 < / t h > < t h > 副 作 用 < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > < c o d e > & a m p ; & a m p ; < / c o d e > < / t d > < t d > 逻 辑 与 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > | | < / c o d e > < / t d > < t d > 逻 辑 或 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > ! < / c o d e > < / t d > < t d > 逻 辑 非 < / t d > < t d > 2 < / t d > < t d > 0 或 1 < / t d > < t d > ❎ < / t d > < / t r > < / t b o d y > < / t a b l e > < u l > < l i > 逻 辑 运 算 符 提 供 逻 辑 判 断 功 能 , 用 于 构 建 更 复 杂 的 表 达 式 , 如 下 所 示 : < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > a < / t h > < t h > b < / t h > < t h > a & a m p ; & a m p ; b < / t h > < t h > a | | b < / t h > < t h > ! a < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > 1 ( 真 ) < / t d > < t d > 1 ( 真 ) < / t d > < t d > 1 ( 真 ) < / t d > < t d > 1 ( 真 ) < / t d > < t d > 0 ( 假 ) < / t d > < / t r > < t r > < t d > 1 ( 真 ) < / t d > < t d > 0 ( 假 ) < / t d > < t d > 0 ( 假 ) < / t d > < t d > 1 ( 真 ) < / t d > < t d > 0 ( 假 ) < / t d > < / t r > < t r > < t d > 0 ( 假 ) < / t d > < t d > 1 ( 真 ) < / t d > < t d > 0 ( 假 ) < / t d > < t d > 1 ( 真 ) < / t d > < t d > 1 ( 真 ) < / t d > < / t r > < t r > < t d > 0 ( 假 ) < / t d > < t d > 0 ( 假 ) < / t d > < t d > 0 ( 假 ) < / t d > < t d > 0 ( 假 ) < / t d > < t d > 1 ( 真 ) < / t d > < / t r > < / t b o d y > < / t a b l e > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 对 于 逻 辑 运 算 符 来 说 , 任 何 非 零 值 都 表 示 真 , 零 值 表 示 假 , 如 : < c o d e > 5 | | 0 < / c o d e > 返 回 < c o d e > 1 < / c o d e > , < c o d e > 5 & a m p ; & a m p ; 0 < / c o d e > 返 回 < c o d e > 0 < / c o d e > 。 < / l i > < l i > ② 短 路 现 象 : < u l > < l i > 对 于 < c o d e > a & a m p ; & a m p ; b < / c o d e > 操 作 来 说 , 当 a 为 假 ( 或 0 ) 时 , 因 为 < c o d e > a & a m p ; & a m p ; b < / c o d e > 结 果 必 定 为 0 , 所 以 不 再 执 行 表 达 式 b 。 < / l i > < l i > 对 于 < c o d e > a | | b < / c o d e > 操 作 来 说 , 当 a 为 真 ( 或 非 0 ) 时 , 因 为 < c o d e > a | | b < / c o d e > 结 果 必 定 为 1 , 所 以 不 再 执 行 表 达 式 b 。 < / l i > < / u l > < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
2024-07-19 09:46:50 +02:00
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 请 输 入 整 数 a 的 值 : & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > scanf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & a m p ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 请 输 入 整 数 b 的 值 : & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > scanf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & a m p ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > if < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , b ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & l t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , b ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , b ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 2 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 短路现象</span></span>
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > j < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > if < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & a m p ; & a m p ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > j < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 床 前 明 月 光 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 这 行 代 码 不 会 执 行 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 我 叫 郭 德 纲 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , j ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < / d i v > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // 短路现象</span></span>
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > j < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > if < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > | | < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > j < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 床 前 明 月 光 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > e l s e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 我 叫 郭 德 纲 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 这 行 代 码 不 会 被 执 行 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , j ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / 1 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
2024-07-19 09:59:59 +02:00
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 2 - 5 - 赋 值 运 算 符 " t a b i n d e x = " - 1 " > 2 . 5 赋 值 运 算 符 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 5 - 赋 值 运 算 符 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 5 赋 值 运 算 符 & q u o t ; " > < / a > < / h 2 > < u l > < l i > 常 见 的 赋 值 运 算 符 , 如 下 所 示 : < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > 运 算 符 < / t h > < t h > 描 述 < / t h > < t h > 操 作 数 个 数 < / t h > < t h > 组 成 的 表 达 式 的 值 < / t h > < t h > 副 作 用 < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > < c o d e > = = < / c o d e > < / t d > < t d > 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > + = < / c o d e > < / t d > < t d > 相 加 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > - = < / c o d e > < / t d > < t d > 相 减 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > * = < / c o d e > < / t d > < t d > 相 乘 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > / = < / c o d e > < / t d > < t d > 相 除 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > % = < / c o d e > < / t d > < t d > 取 余 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > & l t ; & l t ; = < / c o d e > < / t d > < t d > 左 移 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > & g t ; & g t ; = < / c o d e > < / t d > < t d > 右 移 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > & a m p ; = < / c o d e > < / t d > < t d > 按 位 与 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > ^ = < / c o d e > < / t d > < t d > 按 位 异 或 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < t r > < t d > < c o d e > | = < / c o d e > < / t d > < t d > 按 位 或 赋 值 < / t d > < t d > 2 < / t d > < t d > 左 边 操 作 数 的 值 < / t d > < t d > ✅ < / t d > < / t r > < / t b o d y > < / t a b l e > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < u l > < l i > ① 赋 值 运 算 符 的 第 一 个 操 作 数 ( 左 值 ) 必 须 是 变 量 的 形 式 , 第 二 个 操 作 数 可 以 是 任 何 形 式 的 表 达 式 。 < / l i > < l i > ② 赋 值 运 算 符 的 副 作 用 针 对 第 一 个 操 作 数 。 < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
2024-07-19 09:46:50 +02:00
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a = a + 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; a = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / a = 6 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > b < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / b = b - 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; b = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , b ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / b = 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > c < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > * = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / c = c * 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; c = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , c ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / c = 9 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > d < /span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">/ = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d = d / 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; d = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , d ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / d = 1 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > % = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / e = e % 3 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; e = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , e ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / e = 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
2024-07-19 09:59:59 +02:00
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 6 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 2 - 6 - 位 运 算 符 - 了 解 " t a b i n d e x = " - 1 " > 2 . 6 位 运 算 符 ( 了 解 ) < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 6 - 位 运 算 符 - 了 解 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 6 位 运 算 符 ( 了 解 ) & q u o t ; " > < / a > < / h 2 > < h 3 i d = " _ 2 - 6 - 1 - 概 述 " t a b i n d e x = " - 1 " > 2 . 6 . 1 概 述 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 6 - 1 - 概 述 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 6 . 1 概 述 & q u o t ; " > < / a > < / h 3 > < u l > < l i > C 语 言 提 供 了 一 些 位 运 算 符 , 能 够 让 我 们 操 作 二 进 制 位 ( b i t ) 。 < / l i > < l i > 常 见 的 位 运 算 符 , 如 下 所 示 。 < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > 运 算 符 < / t h > < t h > 描 述 < / t h > < t h > 操 作 数 个 数 < / t h > < t h > 运 算 规 则 < / t h > < t h > 副 作 用 < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > < c o d e > & a m p ; < / c o d e > < / t d > < t d > 按 位 与 < / t d > < t d > 2 < / t d > < t d > 两 个 二 进 制 位 都 为 1 , 结 果 为 1 , 否 则 为 0 。 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > | < / c o d e > < / t d > < t d > 按 位 或 < / t d > < t d > 2 < / t d > < t d > 两 个 二 进 制 位 只 要 有 一 个 为 1 ( 包 含 两 个 都 为 1 的 情 况 ) , 结 果 为 1 , 否 则 为 0 。 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > ^ < / c o d e > < / t d > < t d > 按 位 异 或 < / t d > < t d > 2 < / t d > < t d > 两 个 二 进 制 位 一 个 为 0 , 一 个 为 1 , 结 果 为 1 , 否 则 为 0 。 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > ~ < / c o d e > < / t d > < t d > 按 位 取 反 < / t d > < t d > 2 < / t d > < t d > 将 每 一 个 二 进 制 位 变 成 相 反 值 , 即 0 变 成 1 , 1 变 成 0 。 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > & l t ; & l t ; < / c o d e > < / t d > < t d > 二 进 制 左 移 < / t d > < t d > 2 < / t d > < t d > 将 一 个 数 的 各 二 进 制 位 全 部 左 移 指 定 的 位 数 , 左 边 的 二 进 制 位 丢 弃 , 右 边 补 0 。 < / t d > < t d > ❎ < / t d > < / t r > < t r > < t d > < c o d e > & g t ; & g t ; < / c o d e > < / t d > < t d > 二 进 制 右 移 < / t d > < t d > 2 < / t d > < t d > 将 一 个 数 的 各 二 进 制 位 全 部 右 移 指 定 的 位 数 , 正 数 左 补 0 , 负 数 左 补 1 , 右 边 丢 弃 。 < / t d > < t d > ❎ < / t d > < / t r > < / t b o d y > < / t a b l e > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 操 作 数 在 进 行 位 运 算 的 时 候 , 以 它 的 补 码 形 式 计 算 ! ! ! < / p > < / d i v > < h 3 i d = " _ 2 - 6 - 2 - 输 出 二 进 制 位 " t a b i n d e x = " - 1 " > 2 . 6 . 2 输 出 二 进 制 位 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 6 - 2 - 输 出 二 进 制 位 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 6 . 2 输 出 二 进 制 位 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 在 C 语 言 中 , < c o d e > p r i n t f < / c o d e > 是 没 有 提 供 输 出 二 进 制 位 的 格 式 占 位 符 的 ; 但 是 , 我 们 可 以 手 动 实 现 , 以 方 便 后 期 操 作 。 < / p > < / l i > < l i > < p > 示 例 : < / p > < / l i > < / u l > < d i v c l a s s = " l a n g u a g e - c v p - a d a p t i v e - t h e m e l i n e - n u m b e r s - m o d e " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > c < / s p a n > < p r e c l a s s = " s h i k i s h i k i - t h e m e s g i t h u b - l i g h t g i t h u b - d a r k v p - c o d e " t a b i n d e x = " 0 " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > # i n c l u d e < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & l t ; s t d i o . h & g t ; < / s p a n > < / s p a n >
2024-07-19 09:46:50 +02:00
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > / * * < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * 获取指定整数的二进制表示 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > @ p a r a m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # E 3 6 2 0 9 ; - - s h i k i - d a r k : # F F A B 7 0 ; " > n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > 整 数 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > @ r e t u r n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > 二 进 制 表 示 的 字 符 串 , 不 包 括 前 导 的 & # 3 9 ; 0 b & # 3 9 ; 字 符 < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > * / < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > char * < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > g e t B i n a r y < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # E 3 6 2 0 9 ; - - s h i k i - d a r k : # F F A B 7 0 ; " > n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > static < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > c h a r < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # E 3 6 2 0 9 ; - - s h i k i - d a r k : # F F A B 7 0 ; " > b i n a r y S t r i n g < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > [ < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 3 3 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ] ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i , j ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > for < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > s i z e o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( n u m ) < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > * < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 8 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , j < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & g t ; = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; i < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , j < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ) { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > const < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > i n t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b i t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( n u m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & g t ; & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > i ) < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & a m p ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#E36209;--shiki-dark:#FFAB70;" > binaryString < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > [ j ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b i t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > + < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; 0 & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#E36209;--shiki-dark:#FFAB70;" > binaryString < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > [ j ] < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & # 3 9 ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b i n a r y S t r i n g ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > a < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 7 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > b < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > - < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 2 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 整 数 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 的 二 进 制 表 示 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % s < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , a , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > g e t B i n a r y < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( a ) ) ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; 整 数 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > 的 二 进 制 表 示 : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % s < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , b , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > g e t B i n a r y < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( b ) ) ; < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
2024-07-23 03:25:31 +02:00
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 0 < / s p a n > < b r > < / d i v > < / d i v > < h 3 i d = " _ 2 - 6 - 3 - 按 位 与 " t a b i n d e x = " - 1 " > 2 . 6 . 3 按 位 与 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 6 - 3 - 按 位 与 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 6 . 3 按 位 与 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 按 位 与 < c o d e > & a m p ; < / c o d e > 的 运 算 规 则 是 : 如 果 二 进 制 对 应 的 位 上 都 是 1 才 是 1 , 否 则 为 0 , 即 : < / p > < u l > < l i > < c o d e > 1 & a m p ; 1 < / c o d e > 的 结 果 是 < c o d e > 1 < / c o d e > 。 < / l i > < l i > < c o d e > 1 & a m p ; 0 < / c o d e > 的 结 果 是 < c o d e > 0 < / c o d e > 。 < / l i > < l i > < c o d e > 0 & a m p ; 1 < / c o d e > 的 结 果 是 < c o d e > 0 < / c o d e > 。 < / l i > < l i > < c o d e > 0 & a m p ; 0 < / c o d e > 的 结 果 是 < c o d e > 0 < / c o d e > 。 < / l i > < / u l > < / l i > < l i > < p > 示 例 : < c o d e > 9 & a m p ; 7 = 1 < / c o d e > < / p > < / l i > < / u l > < p > < i m g s r c = " ` + o + ' " a l t = " " > < / p > < u l > < l i > 示 例 : < c o d e > - 9 & a m p ; 7 = 7 < / c o d e > < / l i > < / u l > < p > < i m g s r c = " ' + C + ' " a l t = " " > < / p > < h 3 i d = " _ 2 - 6 - 4 - 按 位 或 " t a b i n d e x = " - 1 " > 2 . 6 . 4 按 位 或 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 6 - 4 - 按 位 或 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 6 . 4 按 位 或 & q u o t ; " > < / a > < / h 3 > < u l > < l i > < p > 按 位 与 < c o d e > | < / c o d e > 的 运 算 规 则 是 : 如 果 二 进 制 对 应 的 位 上 只 要 有 1 就 是 1 , 否 则 为 0 , 即 : < / p > < u l > < l i > < c o d e > 1 | 1 < / c o d e > 的 结 果 是 < c o d e > 1 < / c o d e > 。 < / l i > < l i > < c o d e > 1 | 0 < / c o d e > 的 结 果 是 < c o d e > 1 < / c o d e > 。 < / l i > < l i > < c o d e > 0 | 1 < / c o d e > 的 结 果 是 < c o d e > 1 < / c o d e > 。 < / l i > < l i > < c o d e > 0 | 0 < / c o d e > 的 结 果 是 < c o d e > 0 < / c o d e > 。 < / l i > < / u l > < / l i > < l i > < p > 示 例 : < c o d e > 9 | 7 = 1 5 < / c o d e > < / p > < / l i > < / u l > < p > < i m g s r c = " ' + m + ' " a l t = " " > < / p > < u l > < l i > 示 例 : < c o d e > - 9 | 7 = - 9 < / c o d e > < / l i > < / u l > < p > < i m g s r c = " ' + B + ' " a l t = " " > < / p > < h 3 i d = " _ 2 - 6 - 5 - 按 位 异 或 " t a b i n d e x = " - 1 " > 2 . 6 . 5 按 位 异 或 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 6 - 5 - 按 位 异 或 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 6 . 5 按 位 异 或 & q u o t ; " > < / a > < / h 3 > < u l > < l i > 按 位 与 < c o d e > ^ < / c o d e > 的 运 算 规 则 是 : 如 果 二 进 制 对 应 的 位 上 一 个 为 1 一 个 为 0 就 为 1 , 否 则 为 0 , 即 : < u l > < l i > < c o d e > 1 ^ 1 < / c o d e > 的 结 果 是 < c o d e > 0 < / c o d e > 。 < / l i > < l i > < c o d e > 1 ^ 0 < / c o d e > 的 结 果 是 < c o d e > 1 < / c o d e > 。 < / l i > < l i > < c o d e > 0 ^ 1 < / c o d e > 的 结 果 是 < c o d e > 1 < / c o d e > 。 < / l i > < l i > < c o d e > 0 ^ 0 < / c o d e > 的 结 果 是 < c o d e > 0 < / c o d e > 。 < / l i > < / u l > < / l i > < / u l > < d i v c l a s s = " n o t e c u s t o m - b l o c k g i t h u b - a l e r t " > < p c l a s s = " c u s t o m - b l o c k - t i t l e " > N O T E < / p > < p > < / p > < p > 按 位 异 或 的 场 景 有 : < / p > < u l > < l i > ① 交 换 两 个 数 值 : 异 或 操 作 可 以 在 不 使 用 临 时 变 量 的 情 况 下 交 换 两 个 变 量 的 值 。 < / l i > < l i > ② 加 密 或 解 密 : 异 或 操 作 用 于 简 单 的 加 密 和 解 密 算 法 。 < / l i > < l i > ③ 错 误 检 测 和 校 正 : 异 或 操 作 可 以 用 于 奇 偶 校 验 位 的 计 算 和 检 测 错 误 ( R A I D - 3 以 及 以 上 ) 。 < / l i > < l i > … … < / l i > < / u l > < / d i v > < u l > < l i > 示 例 : < c o d e > 9 ^ 7 = 1 4 < / c o d e > < / l i > < / u l > < p > < i m g s r c = " ' + A + ' " a l t = " " > < / p > < u l > < l i > 示 例 : < c o d e > - 9 ^ 7 = - 1 6 < / c o d e > < / l i > < / u l > < p > < i m g s r c = " ' + D + ' " a l t = " " > < / p > < h 3 i d = " _ 2 - 6 - 6 - 按 位 取 反 " t a b i n d e x = " - 1 " > 2 . 6 . 6 按 位 取 反 < a c l a s s
2024-07-19 09:46:50 +02:00
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > m a i n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 1 1 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 2 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > int < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r e s u l t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > & g t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > ? < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > m < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > n ; < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > printf < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; r e s u l t = < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > % d \ \ n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > , r e s u l t ) ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / r e s u l t = 1 1 0 < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#D73A49;--shiki-dark:#F97583;" > return < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 0 5 C C 5 ; - - s h i k i - d a r k : # 7 9 B 8 F F ; " > 0 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ; < / s p a n > < / s p a n >
2024-07-19 09:59:59 +02:00
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < d i v c l a s s = " l i n e - n u m b e r s - w r a p p e r " a r i a - h i d d e n = " t r u e " > < s p a n c l a s s = " l i n e - n u m b e r " > 1 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 2 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 3 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 4 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 5 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 6 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 7 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 8 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 9 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 0 < / s p a n > < b r > < s p a n c l a s s = " l i n e - n u m b e r " > 1 1 < / s p a n > < b r > < / d i v > < / d i v > < h 2 i d = " _ 2 - 8 - 运 算 符 优 先 级 " t a b i n d e x = " - 1 " > 2 . 8 运 算 符 优 先 级 < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # _ 2 - 8 - 运 算 符 优 先 级 " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; 2 . 8 运 算 符 优 先 级 & q u o t ; " > < / a > < / h 2 > < u l > < l i > C 语 言 中 运 算 符 的 优 先 级 , 如 下 所 示 : < / l i > < / u l > < t a b l e t a b i n d e x = " 0 " > < t h e a d > < t r > < t h > < s t r o n g > 优 先 级 < / s t r o n g > < / t h > < t h > < s t r o n g > 运 算 符 < / s t r o n g > < / t h > < t h > < s t r o n g > 名 称 或 含 义 < / s t r o n g > < / t h > < t h > < s t r o n g > 结 合 方 向 < / s t r o n g > < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > < s t r o n g > 1 < / s t r o n g > < / t d > < t d > < c o d e > [ ] < / c o d e > < / t d > < t d > 数 组 下 标 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > ( ) < / c o d e > < / t d > < t d > 圆 括 号 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > . < / c o d e > < / t d > < t d > 成 员 选 择 ( 对 象 ) < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > - & g t ; < / c o d e > < / t d > < t d > 成 员 选 择 ( 指 针 ) < / t d > < t d > < / t d > < / t r > < t r > < t d > < s t r o n g > 2 < / s t r o n g > < / t d > < t d > < c o d e > - < / c o d e > < / t d > < t d > 负 号 运 算 符 < / t d > < t d > 右 到 左 < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > ( 类 型 ) < / c o d e > < / t d > < t d > 强 制 类 型 转 换 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > + + < / c o d e > < / t d > < t d > 自 增 运 算 符 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > - - < / c o d e > < / t d > < t d > 自 减 运 算 符 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > * < / c o d e > < / t d > < t d > 取 值 运 算 符 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > & a m p ; < / c o d e > < / t d > < t d > 取 地 址 运 算 符 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > ! < / c o d e > < / t d > < t d > 逻 辑 非 运 算 符 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > ~ < / c o d e > < / t d > < t d > 按 位 取 反 运 算 符 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > s i z e o f < / c o d e > < / t d > < t d > 长 度 运 算 符 < / t d > < t d > < / t d > < / t r > < t r > < t d > < s t r o n g > 3 < / s t r o n g > < / t d > < t d > < c o d e > / < / c o d e > < / t d > < t d > 除 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > * < / c o d e > < / t d > < t d > 乘 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > % < / c o d e > < / t d > < t d > 余 数 ( 取 模 ) < / t d > < t d > < / t d > < / t r > < t r > < t d > < s t r o n g > 4 < / s t r o n g > < / t d > < t d > < c o d e > + < / c o d e > < / t d > < t d > 加 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > - < / c o d e > < / t d > < t d > 减 < / t d > < t d > < / t d > < / t r > < t r > < t d > < s t r o n g > 5 < / s t r o n g > < / t d > < t d > < c o d e > & l t ; & l t ; < / c o d e > < / t d > < t d > 左 移 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > & g t ; & g t ; < / c o d e > < / t d > < t d > 右 移 < / t d > < t d > < / t d > < / t r > < t r > < t d > < s t r o n g > 6 < / s t r o n g > < / t d > < t d > < c o d e > & g t ; < / c o d e > < / t d > < t d > 大 于 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > & g t ; = < / c o d e > < / t d > < t d > 大 于 等 于 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > & l t ; < / c o d e > < / t d > < t d > 小 于 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > & l t ; = < / c o d e > < / t d > < t d > 小 于 等 于 < / t d > < t d > < / t d > < / t r > < t r > < t d > < s t r o n g > 7 < / s t r o n g > < / t d > < t d > < c o d e > = = < / c o d e > < / t d > < t d > 等 于 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > ! = < / c o d e > < / t d > < t d > 不 等 于 < / t d > < t d > < / t d > < / t r > < t r > < t d > < s t r o n g > 8 < / s t r o n g > < / t d > < t d > < c o d e > & a m p ; < / c o d e > < / t d > < t d > 按 位 与 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < s t r o n g > 9 < / s t r o n g > < / t d > < t d > < c o d e > ^ < / c o d e > < / t d > < t d > 按 位 异 或 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < s t r o n g > 1 0 < / s t r o n g > < / t d > < t d > < c o d e > | < / c o d e > < / t d > < t d > 按 位 或 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < s t r o n g > 1 1 < / s t r o n g > < / t d > < t d > < c o d e > & a m p ; & a m p ; < / c o d e > < / t d > < t d > 逻 辑 与 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < s t r o n g > 1 2 < / s t r o n g > < / t d > < t d > < c o d e > | | < / c o d e > < / t d > < t d > 逻 辑 或 < / t d > < t d > 左 到 右 < / t d > < / t r > < t r > < t d > < s t r o n g > 1 3 < / s t r o n g > < / t d > < t d > < c o d e > ? : < / c o d e > < / t d > < t d > 条 件 运 算 符 < / t d > < t d > 右 到 左 < / t d > < / t r > < t r > < t d > < s t r o n g > 1 4 < / s t r o n g > < / t d > < t d > < c o d e > = < / c o d e > < / t d > < t d > 赋 值 运 算 符 < / t d > < t d > 右 到 左 < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > / = < / c o d e > < / t d > < t d > 除 后 赋 值 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > * = < / c o d e > < / t d > < t d > 乘 后 赋 值 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > % = < / c o d e > < / t d > < t d > 取 模 后 赋 值 < / t d > < t d > < / t d > < / t r > < t r > < t d > < / t d > < t d > < c o d e > + =