<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>m_ngyeong.log</title>
        <link>https://velog.io/</link>
        <description>ʚȉɞ</description>
        <lastBuildDate>Fri, 04 Jul 2025 02:46:36 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>m_ngyeong.log</title>
            <url>https://velog.velcdn.com/images/m_ngyeong/profile/9ac8302c-96fb-4b0f-8945-64e25e105138/image.jpeg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. m_ngyeong.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/m_ngyeong" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[수를 표현하는 방법(진법): Base 2, 8, 10, 16]]></title>
            <link>https://velog.io/@m_ngyeong/%EC%88%98%EB%A5%BC-%ED%91%9C%ED%98%84%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95%EC%A7%84%EB%B2%95-Base-2-8-10-16</link>
            <guid>https://velog.io/@m_ngyeong/%EC%88%98%EB%A5%BC-%ED%91%9C%ED%98%84%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95%EC%A7%84%EB%B2%95-Base-2-8-10-16</guid>
            <pubDate>Fri, 04 Jul 2025 02:46:36 GMT</pubDate>
            <description><![CDATA[<h1 id="진수란">진수란?</h1>
<p>진수는 <strong>숫자를 표현하는 방식</strong>이다. 기본적으로 **몇 개의 숫자를 쓸 수 있느냐(=기수)**로 나뉜다. 아래는 대표적인 4가지 진수야:</p>
<hr>
<h2 id="🌱-2진수binary-base2">🌱 2진수(Binary, Base2)</h2>
<ul>
<li><strong>사용 숫자</strong>: <code>0</code>, <code>1</code></li>
<li><strong>예시</strong>: <code>1011</code>, <code>110</code>, <code>0001</code></li>
<li><strong>용도</strong>: 컴퓨터 내부에서 사용하는 기본 숫자 표현</li>
</ul>
<p><strong>예시 변환</strong>:</p>
<ul>
<li><code>1011(2)</code> = <code>1×2³ + 0×2² + 1×2¹ + 1×2⁰</code> = <code>8 + 0 + 2 + 1</code> = <code>11(10)</code></li>
</ul>
<hr>
<h2 id="🌱-8진수-octal-base8">🌱 8진수 (Octal, Base8)</h2>
<ul>
<li><strong>사용 숫자</strong>: <code>0</code> ~ <code>7</code></li>
<li><strong>예시</strong>: <code>75</code>, <code>0123</code>, <code>177</code></li>
<li><strong>자리수</strong>: <ul>
<li>1의 자리 ... 0 ~ 7 (8종류의 수)</li>
<li>2의 자리 ... 0 ~ 77 (64종류의 수)</li>
<li>3의 자리 ... 0 ~ 777 (512종류의 수)</li>
</ul>
</li>
<li><strong>용도</strong>: 예전 컴퓨터 시스템에서 많이 씀 (예: Unix 파일 권한)</li>
</ul>
<p><strong>예시 변환</strong>:</p>
<ul>
<li><code>75(8)</code> = <code>7×8¹ + 5×8⁰</code> = <code>56 + 5</code> = <code>61(10)</code></li>
<li><code>125(0)</code> = 175(8)
<code>125 ÷ 8 = 15 … 5</code>
<code>15 ÷ 8 = 1 … 7</code>
<code>1 ÷ 8 = 0 … 1</code> (끝)
→ 나머지를 역순으로 읽으면: 1 7 5</li>
</ul>
<h3 id="10진수-↔-8진수octal-변환표-10--255">10진수 ↔ 8진수(Octal) 변환표 (10 ~ 255)</h3>
<table>
<thead>
<tr>
<th>10진수</th>
<th>8진수</th>
<th>10진수</th>
<th>8진수</th>
<th>10진수</th>
<th>8진수</th>
<th>10진수</th>
<th>8진수</th>
</tr>
</thead>
<tbody><tr>
<td>10</td>
<td>12</td>
<td>74</td>
<td>112</td>
<td>138</td>
<td>212</td>
<td>202</td>
<td>312</td>
</tr>
<tr>
<td>11</td>
<td>13</td>
<td>75</td>
<td>113</td>
<td>139</td>
<td>213</td>
<td>203</td>
<td>313</td>
</tr>
<tr>
<td>12</td>
<td>14</td>
<td>76</td>
<td>114</td>
<td>140</td>
<td>214</td>
<td>204</td>
<td>314</td>
</tr>
<tr>
<td>13</td>
<td>15</td>
<td>77</td>
<td>115</td>
<td>141</td>
<td>215</td>
<td>205</td>
<td>315</td>
</tr>
<tr>
<td>14</td>
<td>16</td>
<td>78</td>
<td>116</td>
<td>142</td>
<td>216</td>
<td>206</td>
<td>316</td>
</tr>
<tr>
<td>15</td>
<td>17</td>
<td>79</td>
<td>117</td>
<td>143</td>
<td>217</td>
<td>207</td>
<td>317</td>
</tr>
<tr>
<td>16</td>
<td>20</td>
<td>80</td>
<td>120</td>
<td>144</td>
<td>220</td>
<td>208</td>
<td>320</td>
</tr>
<tr>
<td>17</td>
<td>21</td>
<td>81</td>
<td>121</td>
<td>145</td>
<td>221</td>
<td>209</td>
<td>321</td>
</tr>
<tr>
<td>18</td>
<td>22</td>
<td>82</td>
<td>122</td>
<td>146</td>
<td>222</td>
<td>210</td>
<td>322</td>
</tr>
<tr>
<td>19</td>
<td>23</td>
<td>83</td>
<td>123</td>
<td>147</td>
<td>223</td>
<td>211</td>
<td>323</td>
</tr>
<tr>
<td>20</td>
<td>24</td>
<td>84</td>
<td>124</td>
<td>148</td>
<td>224</td>
<td>212</td>
<td>324</td>
</tr>
<tr>
<td>21</td>
<td>25</td>
<td>85</td>
<td>125</td>
<td>149</td>
<td>225</td>
<td>213</td>
<td>325</td>
</tr>
<tr>
<td>22</td>
<td>26</td>
<td>86</td>
<td>126</td>
<td>150</td>
<td>226</td>
<td>214</td>
<td>326</td>
</tr>
<tr>
<td>23</td>
<td>27</td>
<td>87</td>
<td>127</td>
<td>151</td>
<td>227</td>
<td>215</td>
<td>327</td>
</tr>
<tr>
<td>24</td>
<td>30</td>
<td>88</td>
<td>130</td>
<td>152</td>
<td>230</td>
<td>216</td>
<td>330</td>
</tr>
<tr>
<td>25</td>
<td>31</td>
<td>89</td>
<td>131</td>
<td>153</td>
<td>231</td>
<td>217</td>
<td>331</td>
</tr>
<tr>
<td>26</td>
<td>32</td>
<td>90</td>
<td>132</td>
<td>154</td>
<td>232</td>
<td>218</td>
<td>332</td>
</tr>
<tr>
<td>27</td>
<td>33</td>
<td>91</td>
<td>133</td>
<td>155</td>
<td>233</td>
<td>219</td>
<td>333</td>
</tr>
<tr>
<td>28</td>
<td>34</td>
<td>92</td>
<td>134</td>
<td>156</td>
<td>234</td>
<td>220</td>
<td>334</td>
</tr>
<tr>
<td>29</td>
<td>35</td>
<td>93</td>
<td>135</td>
<td>157</td>
<td>235</td>
<td>221</td>
<td>335</td>
</tr>
<tr>
<td>30</td>
<td>36</td>
<td>94</td>
<td>136</td>
<td>158</td>
<td>236</td>
<td>222</td>
<td>336</td>
</tr>
<tr>
<td>31</td>
<td>37</td>
<td>95</td>
<td>137</td>
<td>159</td>
<td>237</td>
<td>223</td>
<td>337</td>
</tr>
<tr>
<td>32</td>
<td>40</td>
<td>96</td>
<td>140</td>
<td>160</td>
<td>240</td>
<td>224</td>
<td>340</td>
</tr>
<tr>
<td>33</td>
<td>41</td>
<td>97</td>
<td>141</td>
<td>161</td>
<td>241</td>
<td>225</td>
<td>341</td>
</tr>
<tr>
<td>34</td>
<td>42</td>
<td>98</td>
<td>142</td>
<td>162</td>
<td>242</td>
<td>226</td>
<td>342</td>
</tr>
<tr>
<td>35</td>
<td>43</td>
<td>99</td>
<td>143</td>
<td>163</td>
<td>243</td>
<td>227</td>
<td>343</td>
</tr>
<tr>
<td>36</td>
<td>44</td>
<td>100</td>
<td>144</td>
<td>164</td>
<td>244</td>
<td>228</td>
<td>344</td>
</tr>
<tr>
<td>37</td>
<td>45</td>
<td>101</td>
<td>145</td>
<td>165</td>
<td>245</td>
<td>229</td>
<td>345</td>
</tr>
<tr>
<td>38</td>
<td>46</td>
<td>102</td>
<td>146</td>
<td>166</td>
<td>246</td>
<td>230</td>
<td>346</td>
</tr>
<tr>
<td>39</td>
<td>47</td>
<td>103</td>
<td>147</td>
<td>167</td>
<td>247</td>
<td>231</td>
<td>347</td>
</tr>
<tr>
<td>40</td>
<td>50</td>
<td>104</td>
<td>150</td>
<td>168</td>
<td>250</td>
<td>232</td>
<td>350</td>
</tr>
<tr>
<td>41</td>
<td>51</td>
<td>105</td>
<td>151</td>
<td>169</td>
<td>251</td>
<td>233</td>
<td>351</td>
</tr>
<tr>
<td>42</td>
<td>52</td>
<td>106</td>
<td>152</td>
<td>170</td>
<td>252</td>
<td>234</td>
<td>352</td>
</tr>
<tr>
<td>43</td>
<td>53</td>
<td>107</td>
<td>153</td>
<td>171</td>
<td>253</td>
<td>235</td>
<td>353</td>
</tr>
<tr>
<td>44</td>
<td>54</td>
<td>108</td>
<td>154</td>
<td>172</td>
<td>254</td>
<td>236</td>
<td>354</td>
</tr>
<tr>
<td>45</td>
<td>55</td>
<td>109</td>
<td>155</td>
<td>173</td>
<td>255</td>
<td>237</td>
<td>355</td>
</tr>
<tr>
<td>46</td>
<td>56</td>
<td>110</td>
<td>156</td>
<td>174</td>
<td>256</td>
<td>238</td>
<td>356</td>
</tr>
<tr>
<td>47</td>
<td>57</td>
<td>111</td>
<td>157</td>
<td>175</td>
<td>257</td>
<td>239</td>
<td>357</td>
</tr>
<tr>
<td>48</td>
<td>60</td>
<td>112</td>
<td>160</td>
<td>176</td>
<td>260</td>
<td>240</td>
<td>360</td>
</tr>
<tr>
<td>49</td>
<td>61</td>
<td>113</td>
<td>161</td>
<td>177</td>
<td>261</td>
<td>241</td>
<td>361</td>
</tr>
<tr>
<td>50</td>
<td>62</td>
<td>114</td>
<td>162</td>
<td>178</td>
<td>262</td>
<td>242</td>
<td>362</td>
</tr>
<tr>
<td>51</td>
<td>63</td>
<td>115</td>
<td>163</td>
<td>179</td>
<td>263</td>
<td>243</td>
<td>363</td>
</tr>
<tr>
<td>52</td>
<td>64</td>
<td>116</td>
<td>164</td>
<td>180</td>
<td>264</td>
<td>244</td>
<td>364</td>
</tr>
<tr>
<td>53</td>
<td>65</td>
<td>117</td>
<td>165</td>
<td>181</td>
<td>265</td>
<td>245</td>
<td>365</td>
</tr>
<tr>
<td>54</td>
<td>66</td>
<td>118</td>
<td>166</td>
<td>182</td>
<td>266</td>
<td>246</td>
<td>366</td>
</tr>
<tr>
<td>55</td>
<td>67</td>
<td>119</td>
<td>167</td>
<td>183</td>
<td>267</td>
<td>247</td>
<td>367</td>
</tr>
<tr>
<td>56</td>
<td>70</td>
<td>120</td>
<td>170</td>
<td>184</td>
<td>270</td>
<td>248</td>
<td>370</td>
</tr>
<tr>
<td>57</td>
<td>71</td>
<td>121</td>
<td>171</td>
<td>185</td>
<td>271</td>
<td>249</td>
<td>371</td>
</tr>
<tr>
<td>58</td>
<td>72</td>
<td>122</td>
<td>172</td>
<td>186</td>
<td>272</td>
<td>250</td>
<td>372</td>
</tr>
<tr>
<td>59</td>
<td>73</td>
<td>123</td>
<td>173</td>
<td>187</td>
<td>273</td>
<td>251</td>
<td>373</td>
</tr>
<tr>
<td>60</td>
<td>74</td>
<td>124</td>
<td>174</td>
<td>188</td>
<td>274</td>
<td>252</td>
<td>374</td>
</tr>
<tr>
<td>61</td>
<td>75</td>
<td>125</td>
<td>175</td>
<td>189</td>
<td>275</td>
<td>253</td>
<td>375</td>
</tr>
<tr>
<td>62</td>
<td>76</td>
<td>126</td>
<td>176</td>
<td>190</td>
<td>276</td>
<td>254</td>
<td>376</td>
</tr>
<tr>
<td>63</td>
<td>77</td>
<td>127</td>
<td>177</td>
<td>191</td>
<td>277</td>
<td>255</td>
<td>377</td>
</tr>
<tr>
<td>64</td>
<td>100</td>
<td>128</td>
<td>200</td>
<td>192</td>
<td>300</td>
<td></td>
<td></td>
</tr>
<tr>
<td>65</td>
<td>101</td>
<td>129</td>
<td>201</td>
<td>193</td>
<td>301</td>
<td></td>
<td></td>
</tr>
<tr>
<td>66</td>
<td>102</td>
<td>130</td>
<td>202</td>
<td>194</td>
<td>302</td>
<td></td>
<td></td>
</tr>
<tr>
<td>67</td>
<td>103</td>
<td>131</td>
<td>203</td>
<td>195</td>
<td>303</td>
<td></td>
<td></td>
</tr>
<tr>
<td>68</td>
<td>104</td>
<td>132</td>
<td>204</td>
<td>196</td>
<td>304</td>
<td></td>
<td></td>
</tr>
<tr>
<td>69</td>
<td>105</td>
<td>133</td>
<td>205</td>
<td>197</td>
<td>305</td>
<td></td>
<td></td>
</tr>
<tr>
<td>70</td>
<td>106</td>
<td>134</td>
<td>206</td>
<td>198</td>
<td>306</td>
<td></td>
<td></td>
</tr>
<tr>
<td>71</td>
<td>107</td>
<td>135</td>
<td>207</td>
<td>199</td>
<td>307</td>
<td></td>
<td></td>
</tr>
<tr>
<td>72</td>
<td>110</td>
<td>136</td>
<td>210</td>
<td>200</td>
<td>310</td>
<td></td>
<td></td>
</tr>
<tr>
<td>73</td>
<td>111</td>
<td>137</td>
<td>211</td>
<td>201</td>
<td>311</td>
<td></td>
<td></td>
</tr>
</tbody></table>
<hr>
<h2 id="🌱-10진수-decimal-base10">🌱 10진수 (Decimal, Base10)</h2>
<ul>
<li><strong>사용 숫자</strong>: <code>0</code> ~ <code>9</code></li>
<li><strong>예시</strong>: <code>42</code>, <code>1234</code>, <code>2025</code></li>
<li><strong>용도</strong>: 우리가 일상에서 쓰는 숫자</li>
</ul>
<hr>
<h2 id="🌱-16진수-hexadecimal-base16">🌱 16진수 (Hexadecimal, Base16)</h2>
<ul>
<li><strong>사용 숫자</strong>: <code>0</code> ~ <code>9</code> + <code>A</code>(10), <code>B</code>(11), <code>C</code>(12), <code>D</code>(13), <code>E</code>(14), <code>F</code>(15)</li>
<li><strong>예시</strong>: <code>2F</code>, <code>0xA3</code>, <code>1B4</code></li>
<li><strong>용도</strong>: 메모리 주소, 색상 코드, 낮은 수준 프로그래밍 등</li>
</ul>
<p><strong>예시 변환</strong>:</p>
<ul>
<li><code>2F(16)</code> = <code>2×16¹ + 15×16⁰</code> = <code>32 + 15</code> = <code>47(10)</code></li>
<li><code>125(0)</code> = 7D(16)
<code>125 ÷ 16 = 7 … 13 → D</code>
<code>7 ÷ 16 = 0 … 7</code> (끝)
→ 나머지를 역순으로 읽으면: 7 D</li>
</ul>
<h3 id="10진수-↔-16진수hex-변환표-10--255">10진수 ↔ 16진수(Hex) 변환표 (10 ~ 255)</h3>
<table>
<thead>
<tr>
<th>10진수</th>
<th>16진수</th>
<th>10진수</th>
<th>16진수</th>
<th>10진수</th>
<th>16진수</th>
<th>10진수</th>
<th>16진수</th>
</tr>
</thead>
<tbody><tr>
<td>10</td>
<td>A</td>
<td>74</td>
<td>4A</td>
<td>138</td>
<td>8A</td>
<td>202</td>
<td>CA</td>
</tr>
<tr>
<td>11</td>
<td>B</td>
<td>75</td>
<td>4B</td>
<td>139</td>
<td>8B</td>
<td>203</td>
<td>CB</td>
</tr>
<tr>
<td>12</td>
<td>C</td>
<td>76</td>
<td>4C</td>
<td>140</td>
<td>8C</td>
<td>204</td>
<td>CC</td>
</tr>
<tr>
<td>13</td>
<td>D</td>
<td>77</td>
<td>4D</td>
<td>141</td>
<td>8D</td>
<td>205</td>
<td>CD</td>
</tr>
<tr>
<td>14</td>
<td>E</td>
<td>78</td>
<td>4E</td>
<td>142</td>
<td>8E</td>
<td>206</td>
<td>CE</td>
</tr>
<tr>
<td>15</td>
<td>F</td>
<td>79</td>
<td>4F</td>
<td>143</td>
<td>8F</td>
<td>207</td>
<td>CF</td>
</tr>
<tr>
<td>16</td>
<td>10</td>
<td>80</td>
<td>50</td>
<td>144</td>
<td>90</td>
<td>208</td>
<td>D0</td>
</tr>
<tr>
<td>17</td>
<td>11</td>
<td>81</td>
<td>51</td>
<td>145</td>
<td>91</td>
<td>209</td>
<td>D1</td>
</tr>
<tr>
<td>18</td>
<td>12</td>
<td>82</td>
<td>52</td>
<td>146</td>
<td>92</td>
<td>210</td>
<td>D2</td>
</tr>
<tr>
<td>19</td>
<td>13</td>
<td>83</td>
<td>53</td>
<td>147</td>
<td>93</td>
<td>211</td>
<td>D3</td>
</tr>
<tr>
<td>20</td>
<td>14</td>
<td>84</td>
<td>54</td>
<td>148</td>
<td>94</td>
<td>212</td>
<td>D4</td>
</tr>
<tr>
<td>21</td>
<td>15</td>
<td>85</td>
<td>55</td>
<td>149</td>
<td>95</td>
<td>213</td>
<td>D5</td>
</tr>
<tr>
<td>22</td>
<td>16</td>
<td>86</td>
<td>56</td>
<td>150</td>
<td>96</td>
<td>214</td>
<td>D6</td>
</tr>
<tr>
<td>23</td>
<td>17</td>
<td>87</td>
<td>57</td>
<td>151</td>
<td>97</td>
<td>215</td>
<td>D7</td>
</tr>
<tr>
<td>24</td>
<td>18</td>
<td>88</td>
<td>58</td>
<td>152</td>
<td>98</td>
<td>216</td>
<td>D8</td>
</tr>
<tr>
<td>25</td>
<td>19</td>
<td>89</td>
<td>59</td>
<td>153</td>
<td>99</td>
<td>217</td>
<td>D9</td>
</tr>
<tr>
<td>26</td>
<td>1A</td>
<td>90</td>
<td>5A</td>
<td>154</td>
<td>9A</td>
<td>218</td>
<td>DA</td>
</tr>
<tr>
<td>27</td>
<td>1B</td>
<td>91</td>
<td>5B</td>
<td>155</td>
<td>9B</td>
<td>219</td>
<td>DB</td>
</tr>
<tr>
<td>28</td>
<td>1C</td>
<td>92</td>
<td>5C</td>
<td>156</td>
<td>9C</td>
<td>220</td>
<td>DC</td>
</tr>
<tr>
<td>29</td>
<td>1D</td>
<td>93</td>
<td>5D</td>
<td>157</td>
<td>9D</td>
<td>221</td>
<td>DD</td>
</tr>
<tr>
<td>30</td>
<td>1E</td>
<td>94</td>
<td>5E</td>
<td>158</td>
<td>9E</td>
<td>222</td>
<td>DE</td>
</tr>
<tr>
<td>31</td>
<td>1F</td>
<td>95</td>
<td>5F</td>
<td>159</td>
<td>9F</td>
<td>223</td>
<td>DF</td>
</tr>
<tr>
<td>32</td>
<td>20</td>
<td>96</td>
<td>60</td>
<td>160</td>
<td>A0</td>
<td>224</td>
<td>E0</td>
</tr>
<tr>
<td>33</td>
<td>21</td>
<td>97</td>
<td>61</td>
<td>161</td>
<td>A1</td>
<td>225</td>
<td>E1</td>
</tr>
<tr>
<td>34</td>
<td>22</td>
<td>98</td>
<td>62</td>
<td>162</td>
<td>A2</td>
<td>226</td>
<td>E2</td>
</tr>
<tr>
<td>35</td>
<td>23</td>
<td>99</td>
<td>63</td>
<td>163</td>
<td>A3</td>
<td>227</td>
<td>E3</td>
</tr>
<tr>
<td>36</td>
<td>24</td>
<td>100</td>
<td>64</td>
<td>164</td>
<td>A4</td>
<td>228</td>
<td>E4</td>
</tr>
<tr>
<td>37</td>
<td>25</td>
<td>101</td>
<td>65</td>
<td>165</td>
<td>A5</td>
<td>229</td>
<td>E5</td>
</tr>
<tr>
<td>38</td>
<td>26</td>
<td>102</td>
<td>66</td>
<td>166</td>
<td>A6</td>
<td>230</td>
<td>E6</td>
</tr>
<tr>
<td>39</td>
<td>27</td>
<td>103</td>
<td>67</td>
<td>167</td>
<td>A7</td>
<td>231</td>
<td>E7</td>
</tr>
<tr>
<td>40</td>
<td>28</td>
<td>104</td>
<td>68</td>
<td>168</td>
<td>A8</td>
<td>232</td>
<td>E8</td>
</tr>
<tr>
<td>41</td>
<td>29</td>
<td>105</td>
<td>69</td>
<td>169</td>
<td>A9</td>
<td>233</td>
<td>E9</td>
</tr>
<tr>
<td>42</td>
<td>2A</td>
<td>106</td>
<td>6A</td>
<td>170</td>
<td>AA</td>
<td>234</td>
<td>EA</td>
</tr>
<tr>
<td>43</td>
<td>2B</td>
<td>107</td>
<td>6B</td>
<td>171</td>
<td>AB</td>
<td>235</td>
<td>EB</td>
</tr>
<tr>
<td>44</td>
<td>2C</td>
<td>108</td>
<td>6C</td>
<td>172</td>
<td>AC</td>
<td>236</td>
<td>EC</td>
</tr>
<tr>
<td>45</td>
<td>2D</td>
<td>109</td>
<td>6D</td>
<td>173</td>
<td>AD</td>
<td>237</td>
<td>ED</td>
</tr>
<tr>
<td>46</td>
<td>2E</td>
<td>110</td>
<td>6E</td>
<td>174</td>
<td>AE</td>
<td>238</td>
<td>EE</td>
</tr>
<tr>
<td>47</td>
<td>2F</td>
<td>111</td>
<td>6F</td>
<td>175</td>
<td>AF</td>
<td>239</td>
<td>EF</td>
</tr>
<tr>
<td>48</td>
<td>30</td>
<td>112</td>
<td>70</td>
<td>176</td>
<td>B0</td>
<td>240</td>
<td>F0</td>
</tr>
<tr>
<td>49</td>
<td>31</td>
<td>113</td>
<td>71</td>
<td>177</td>
<td>B1</td>
<td>241</td>
<td>F1</td>
</tr>
<tr>
<td>50</td>
<td>32</td>
<td>114</td>
<td>72</td>
<td>178</td>
<td>B2</td>
<td>242</td>
<td>F2</td>
</tr>
<tr>
<td>51</td>
<td>33</td>
<td>115</td>
<td>73</td>
<td>179</td>
<td>B3</td>
<td>243</td>
<td>F3</td>
</tr>
<tr>
<td>52</td>
<td>34</td>
<td>116</td>
<td>74</td>
<td>180</td>
<td>B4</td>
<td>244</td>
<td>F4</td>
</tr>
<tr>
<td>53</td>
<td>35</td>
<td>117</td>
<td>75</td>
<td>181</td>
<td>B5</td>
<td>245</td>
<td>F5</td>
</tr>
<tr>
<td>54</td>
<td>36</td>
<td>118</td>
<td>76</td>
<td>182</td>
<td>B6</td>
<td>246</td>
<td>F6</td>
</tr>
<tr>
<td>55</td>
<td>37</td>
<td>119</td>
<td>77</td>
<td>183</td>
<td>B7</td>
<td>247</td>
<td>F7</td>
</tr>
<tr>
<td>56</td>
<td>38</td>
<td>120</td>
<td>78</td>
<td>184</td>
<td>B8</td>
<td>248</td>
<td>F8</td>
</tr>
<tr>
<td>57</td>
<td>39</td>
<td>121</td>
<td>79</td>
<td>185</td>
<td>B9</td>
<td>249</td>
<td>F9</td>
</tr>
<tr>
<td>58</td>
<td>3A</td>
<td>122</td>
<td>7A</td>
<td>186</td>
<td>BA</td>
<td>250</td>
<td>FA</td>
</tr>
<tr>
<td>59</td>
<td>3B</td>
<td>123</td>
<td>7B</td>
<td>187</td>
<td>BB</td>
<td>251</td>
<td>FB</td>
</tr>
<tr>
<td>60</td>
<td>3C</td>
<td>124</td>
<td>7C</td>
<td>188</td>
<td>BC</td>
<td>252</td>
<td>FC</td>
</tr>
<tr>
<td>61</td>
<td>3D</td>
<td>125</td>
<td>7D</td>
<td>189</td>
<td>BD</td>
<td>253</td>
<td>FD</td>
</tr>
<tr>
<td>62</td>
<td>3E</td>
<td>126</td>
<td>7E</td>
<td>190</td>
<td>BE</td>
<td>254</td>
<td>FE</td>
</tr>
<tr>
<td>63</td>
<td>3F</td>
<td>127</td>
<td>7F</td>
<td>191</td>
<td>BF</td>
<td>255</td>
<td>FF</td>
</tr>
<tr>
<td>64</td>
<td>40</td>
<td>128</td>
<td>80</td>
<td>192</td>
<td>C0</td>
<td></td>
<td></td>
</tr>
<tr>
<td>65</td>
<td>41</td>
<td>129</td>
<td>81</td>
<td>193</td>
<td>C1</td>
<td></td>
<td></td>
</tr>
<tr>
<td>66</td>
<td>42</td>
<td>130</td>
<td>82</td>
<td>194</td>
<td>C2</td>
<td></td>
<td></td>
</tr>
<tr>
<td>67</td>
<td>43</td>
<td>131</td>
<td>83</td>
<td>195</td>
<td>C3</td>
<td></td>
<td></td>
</tr>
<tr>
<td>68</td>
<td>44</td>
<td>132</td>
<td>84</td>
<td>196</td>
<td>C4</td>
<td></td>
<td></td>
</tr>
<tr>
<td>69</td>
<td>45</td>
<td>133</td>
<td>85</td>
<td>197</td>
<td>C5</td>
<td></td>
<td></td>
</tr>
<tr>
<td>70</td>
<td>46</td>
<td>134</td>
<td>86</td>
<td>198</td>
<td>C6</td>
<td></td>
<td></td>
</tr>
<tr>
<td>71</td>
<td>47</td>
<td>135</td>
<td>87</td>
<td>199</td>
<td>C7</td>
<td></td>
<td></td>
</tr>
<tr>
<td>72</td>
<td>48</td>
<td>136</td>
<td>88</td>
<td>200</td>
<td>C8</td>
<td></td>
<td></td>
</tr>
<tr>
<td>73</td>
<td>49</td>
<td>137</td>
<td>89</td>
<td>201</td>
<td>C9</td>
<td></td>
<td></td>
</tr>
</tbody></table>
<hr>
<h2 id="요약-비교">요약 비교</h2>
<table>
<thead>
<tr>
<th>진수</th>
<th>기수</th>
<th>사용 숫자</th>
<th>예시</th>
<th>10진수 변환</th>
</tr>
</thead>
<tbody><tr>
<td>2진수</td>
<td>2</td>
<td>0, 1</td>
<td>1011</td>
<td>11</td>
</tr>
<tr>
<td>8진수</td>
<td>8</td>
<td>0 ~ 7</td>
<td>75</td>
<td>61</td>
</tr>
<tr>
<td>10진수</td>
<td>10</td>
<td>0 ~ 9</td>
<td>42</td>
<td>42</td>
</tr>
<tr>
<td>16진수</td>
<td>16</td>
<td>0 ~ 9, A ~ F</td>
<td>2F</td>
<td>47</td>
</tr>
</tbody></table>
<hr>
<p>필요하면 진수 변환하는 방법도 구체적으로 설명해줄게.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[🫐 빅분기 실기 준비]]></title>
            <link>https://velog.io/@m_ngyeong/%EB%B9%85%EB%B6%84%EA%B8%B0-%EC%8B%A4%EA%B8%B0-%EC%A4%80%EB%B9%84</link>
            <guid>https://velog.io/@m_ngyeong/%EB%B9%85%EB%B6%84%EA%B8%B0-%EC%8B%A4%EA%B8%B0-%EC%A4%80%EB%B9%84</guid>
            <pubDate>Sun, 15 Jun 2025 13:26:44 GMT</pubDate>
            <description><![CDATA[<h1 id="빅데이터-분서-기사-실기">빅데이터 분서 기사 실기</h1>
<ul>
<li><p>실기 체험 환경: <a href="https://dataq.goorm.io/exam/3/%EC%B2%B4%ED%97%98%ED%95%98%EA%B8%B0/quiz/1">https://dataq.goorm.io/exam/3/%EC%B2%B4%ED%97%98%ED%95%98%EA%B8%B0/quiz/1</a></p>
<h2 id="help-dir-적극-활용-">help(), dir() 적극 활용 !!!!!!!</h2>
</li>
<li><p>help(): <strong>도움말</strong>(docstring)을 출력</p>
</li>
<li><p>dir(): 객체가 가지고 있는 <strong>속성과 메서드(함수) 목록</strong> 출력</p>
</li>
</ul>
<pre><code class="language-python">import pandas as pd

#dir을 통해 사용 가능한 함수 확인
print(dir(pd))
print(dir(pd.DataFrame))

import sklearn
print(sklearn.__all__)

# 전처리 무엇을 할 수 있지?
import sklearn.preprocessing
print(sklearn.preprocessing.__all__)</code></pre>
<hr>
<h2 id="🦋-제-1유형10점-문제-3개-수행-순서와-답-계산">🦋 제 1유형(<strong>10점, 문제 3개</strong>): <strong>수행 순서</strong>와 <strong>답</strong> 계산</h2>
<h3 id="iqr이상치">IQR(이상치)</h3>
<p>데이터 중에서 너무 크거나 작은 값(이상치) 들을 걸러내기 위해 사용한다.</p>
<pre><code class="language-python">Q1 = df[col].quantile(0.25)   # 1사분위수 (하위 25%)
Q3 = df[col].quantile(0.75)   # 3사분위수 (상위 25%)
IQR = Q3 - Q1                 # IQR: 중간 50% 범위

# 이상치 기준 범위
하한 = Q1 - 1.5 * IQR
상한 = Q3 + 1.5 * IQR</code></pre>
<ul>
<li><code>quantile()</code>: <strong>데이터의 분위수</strong>를 계산할 때 사용하는 함수
0.25 분위수(=1사분위수), 0.5 분위수(=중앙값), 0.75 분위수(=3사분위수)<h2 id="🦋-제-2유형40점-문제-1개">🦋 제 2유형(<strong>40점, 문제 1개</strong>):</h2>
<h3 id="1-데이터-유형-파악">1. 데이터 유형 파악</h3>
</li>
</ul>
<h4 id="▪️-info--info">▪️ .info() / .info</h4>
<pre><code class="language-python">print(train.info())</code></pre>
<h4 id="▪️-shape--튜플-형태로-배열-정보-확인">▪️ .shape : 튜플 형태로 배열 정보 확인</h4>
<pre><code class="language-python">print(X_train.shape)</code></pre>
<h3 id="2-데이터-전처리">2. 데이터 전처리</h3>
<h4 id="1-독립변수종속변수-분리-traintest-set-분리">(1) 독립변수/종속변수 분리, train/test set 분리</h4>
<ul>
<li><strong><code>axis = 0</code></strong>: 아래로 내려가면서 계산 → <strong>열(세로)</strong>을 따라 계산</li>
<li><strong><code>axis = 1</code></strong>: 옆으로 가면서 계산 → <strong>행(가로)</strong>을 따라 계산
⚠️ <code>행은 가로 = 행거는 가로</code></li>
</ul>
<pre><code class="language-python">import pandas as pd

df = pd.DataFrame({
    &#39;A&#39;: [1, 2, 3],
    &#39;B&#39;: [4, 5, 6]
})
print(df)
&#39;&#39;&#39;
   A  B
0  1  4
1  2  5
2  3  6
&#39;&#39;&#39;

print(df.sum(axis=0)) # → 각 열의 합
print(df.sum(axis=1)) # → 각 행의 합
&#39;&#39;&#39;
A     6
B    15

0     5
1     7
2     9
&#39;&#39;&#39;</code></pre>
<h4 id="2-결측치-처리-fillna">(2) 결측치 처리: <code>fillna()</code></h4>
<pre><code class="language-python"># 환불금액에 결측치가 있다는 건 환불을 하지 않았다는 의미로 볼 수 있음
X_trian[&#39;환불금액&#39;] = X_trian[&#39;환불금액&#39;].fillna(0)
X_test[&#39;환불금액&#39;] = X_test[&#39;환불금액&#39;].fillna(0)

print(X_trian.isna().sum())
print(X_test.isna().sum())</code></pre>
<h4 id="3-수치형-변수-스케일링">(3) 수치형 변수 스케일링</h4>
<p>Why? 강수량 값이 크다고 해서 중요하다는 뜻이 아니기 때문에 같은 스케일로 바꿔야한다.</p>
<ul>
<li><p><strong>Min-Max Scaling</strong>(최소-최대 정규화) : <strong>0~1 사이로 정규화</strong>
$$
X_{\text{scaled}} = \frac{X - X_{\text{min}}}{X_{\text{max}} - X_{\text{min}}}
$$</p>
<pre><code class="language-python"># 🔧 scikit-learn
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
num_columns = X_trian.select_dtypes(exclude=&#39;object&#39;).columns # 범주형 변수를 제외하고 수치형 변수만 가져옴
X_trian[num_columns] = scaler.fit_transform(X_trian[num_columns]) # fit_transform(): 학습 → 적용
X_test[num_columns] = scaler.transform(X_test[num_columns])       # transform(): 적용</code></pre>
<ul>
<li>범위: <strong><code>0 ~ 1</code> / <code>-1 ~ 1</code></strong></li>
<li>민감도: 이상치에 민감</li>
<li>사용처: 이미지, 딥러닝 등</li>
</ul>
</li>
<li><p><strong>Standard Scaling</strong>(표준화, Z-score 정규화): <strong>정규분포 기반</strong>
$$
X_{\text{scaled}} = \frac{X - \mu}{\sigma}
$$</p>
<p>(평균: μ, 표준편차: σ)</p>
<pre><code class="language-python"># 🔧 scikit-lear
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)</code></pre>
<ul>
<li>범위: <strong><code>평균 0, 표준편차 1</code></strong></li>
<li>민감도: 상대적으로 안정적이며, 데이터가 정규분포에 가까울수록 효과적</li>
<li>사용처:  회귀, PCA 등</li>
</ul>
</li>
</ul>
<h4 id="4-범주형-변수object-인코딩">(4) 범주형 변수(Object) 인코딩</h4>
<p>why? &quot;Sunny&quot;, &quot;Rainy&quot;가 같은 문자열은 컴퓨터가 이해하지 못하기 때문에 숫자를 부여할 필요가 있음.</p>
<ul>
<li><p><strong>Label Encoding</strong>(라벨 인코딩):</p>
<pre><code class="language-python">[&#39;피자&#39;, &#39;치킨&#39;, &#39;콜라&#39;] → [0, 1, 2]

# 🔧 scikit-lear
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()
X_trian[&#39;encoded&#39;] = le.fit_transform(X_trian[&#39;food&#39;])
X_test[&#39;encoded&#39;] = le.fit_transform(X_test[&#39;food&#39;])</code></pre>
<ul>
<li>순서 없음</li>
<li>트리 기반 모델(<strong>RandomForest</strong>, XGBoost 등)에 주로 사용됨</li>
<li><strong>각 범주에 숫자 ID 부여</strong></li>
</ul>
</li>
<li><p><strong>One-Hot Encoding</strong>(원-핫 인코딩): </p>
<ul>
<li>fit → transform → DataFrame → concat<pre><code class="language-python">&#39;피자&#39; → [1, 0, 0]
&#39;치킨&#39; → [0, 1, 0]
&#39;콜라&#39; → [0, 0, 1]
</code></pre>
</li>
</ul>
<p>pd.get_dummies(df[&#39;food&#39;])</p>
<h1 id="🔧-scikit-lear">🔧 scikit-lear</h1>
<p>from sklearn.preprocessing import OneHotEncoder
ohe = OneHotEncoder(sparse_output=False)
cat_cols = [&#39;C1&#39;, &#39;C2&#39;, &#39;C3&#39;, &#39;C4&#39;]</p>
<p>ohe.fit(X_trian[cat_cols])</p>
<h1 id="dataframe--get_feature_names_out--열-이름-복원">DataFrame = get_feature_names_out() : 열 이름 복원</h1>
<p>X_train_ohe = pd.DataFrame(ohe.transform(X_trian[cat_cols]), columns=ohe.get_feature_names_out(cat_cols), index=X_trian.index)
X_test_ohe = pd.DataFrame(ohe.transform(X_test[cat_cols]), columns=ohe.get_feature_names_out(cat_cols), index=X_test.index)</p>
<h1 id="기존-범주형-변수-제거하고-인코딩된-것-추가">기존 범주형 변수 제거하고 인코딩된 것 추가</h1>
<p>X_trian = pd.concat([X_trian.drop(columns=cat_cols), X_train_ohe], axis=1)
X_test = pd.concat([X_test.drop(columns=cat_cols), X_test_ohe], axis=1)</p>
<pre><code>- 각 범주를 이진 벡터로 변환
- 선형 모델(**Linear Regression**, Logistic 등)에 주로 사용됨
- **범주마다 새로운 열 생성**
</code></pre></li>
</ul>
<h3 id="3-데이터-분리-train_test_split">3. 데이터 분리: <code>train_test_split()</code></h3>
<ul>
<li>전체 데이터셋을 <strong>훈련(train)</strong>과 <strong>검증(validation)</strong>으로 나누어:<ul>
<li><strong>모델 학습</strong>은 <code>X_trian</code>, <code>y_train</code>으로 진행하고,</li>
<li>학습한 모델의 성능을 <strong>검증용</strong> 데이터 <code>X_val</code>, <code>y_val</code>에서 평가</li>
</ul>
</li>
</ul>
<table>
<thead>
<tr>
<th align="center">요소</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>X_trian</code></td>
<td>훈련용 입력 데이터 (독립 변수)</td>
</tr>
<tr>
<td align="center"><code>X_val</code></td>
<td>검증용 입력 데이터</td>
</tr>
<tr>
<td align="center"><code>y_train</code></td>
<td>훈련용 타깃 값 (종속 변수, 예: 지하철 이용자 수)</td>
</tr>
<tr>
<td align="center"><code>y_val</code></td>
<td>검증용 타깃 값</td>
</tr>
</tbody></table>
<pre><code class="language-python">from sklearn.model_selection import train_test_split
X_trian, X_val, y_train, y_val = train_test_split(X_trian, y, test_size=0.2)
print(X_trian.shape, X_val.shape, y_train.shape, y_val.shape)</code></pre>
<ul>
<li><code>train_test_split(X_trian, y, test_size=0.2)</code>:<ul>
<li><code>X_trian</code>: 독립 변수 데이터 (특징 변수)</li>
<li><code>y</code>: 종속 변수 (목표값, 예: 지하철 이용자 수)</li>
<li><code>test_size=0.2</code>: 전체 데이터 중 <strong>20%를 검증용(validation)</strong>으로 사용하겠다는 의미
➡️ 즉, 80%는 훈련용, 20%는 검증용</li>
</ul>
</li>
</ul>
<h3 id="4-모델-학습-및-검증">4. 모델 학습 및 검증</h3>
<h4 id="▪️-분류randomforestclassifier">▪️ 분류(RandomForestClassifier)</h4>
<pre><code class="language-python">from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
model.fit(X_train, y_train) # 모델 학습
y_val_pred = model.predict(X_val)</code></pre>
<ul>
<li>다중 분류: <code>LabelEncoder</code> → A B C D E → 0 1 2 3 4 → <code>inverser_transform</code> → A B C D E</li>
</ul>
<h4 id="▪️-회귀randomforestregressor">▪️ 회귀(RandomForestRegressor)</h4>
<pre><code class="language-python">from sklearn.ensemble import RandomForestRegressor
model = RandomForestRegressor()
model.fit(X_trian, y_train)
y_val_pred = model.predict(X_val)</code></pre>
<h4 id="로지스틱--다중-선형-회귀-모델">로지스틱 / 다중 선형 회귀 모델</h4>
<pre><code class="language-python">import statsmodels.api as sm
X = sm.add_constant(X) # 상수항 추가

model = 
print(f&quot;회귀계수: {model.params[]}&quot;)</code></pre>
<ul>
<li>로지스틱: <code>sm.Logit(y, X).fit()</code></li>
<li>다중 선형: <code>sm.OLS(y, X).fit()</code></li>
</ul>
<h4 id="🆚-차이">🆚 차이</h4>
<table>
<thead>
<tr>
<th>기준</th>
<th>회귀 (Regression)</th>
<th>분류 (Classification)</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Y 값의 형태</strong></td>
<td><strong>연속형 숫자 (실수, 정수)</strong></td>
<td><strong>범주형 (클래스, 라벨)</strong></td>
</tr>
<tr>
<td><strong>예:</strong></td>
<td>집값, 온도, 매출액, 승객 수</td>
<td>스팸/햄, 질병 유무, 숫자 0~9</td>
</tr>
<tr>
<td><strong>예측 결과</strong></td>
<td>실수 값 출력</td>
<td>클래스(범주) 출력</td>
</tr>
<tr>
<td><strong>평가지표</strong></td>
<td>MAE, MSE, RMSE, R² 등</td>
<td>정확도, F1-score, ROC-AUC 등</td>
</tr>
</tbody></table>
<h3 id="5-평가">5. 평가</h3>
<h4 id="▪️-분류-roc_auc_score-accuracy_score">▪️ 분류: roc_auc_score, accuracy_score</h4>
<ul>
<li><strong>ROC 곡선 아래 면적(ROC Auc Score)</strong>: <ul>
<li>ROC 곡선(Receiver Operating Characteristic curve)은 <strong>참 양성 비율(TPR)</strong>과 <strong>거짓 양성 비율(FPR)</strong>의 변화를 나타내는 곡선으로, 분류기가 얼마나 잘 구분하는지(클래스 간 분리도)를 수치로 나타냄.</li>
<li><strong>최대 1.0</strong>으로, 1에 가까울수록 성능이 좋음.</li>
</ul>
</li>
<li><strong>정확도(Accuracy Score)</strong>: <ul>
<li>맞게 예측한 샘플의 <strong>비율</strong></li>
<li><strong>최대 1.0</strong>으로, 1에 가까울수록 성능이 좋음.</li>
</ul>
</li>
</ul>
<p>$$
  \text{Accuracy} = \frac{\text{정확히 맞춘 샘플 수}}{\text{전체 샘플 수}}
  $$</p>
<pre><code class="language-python">from sklearn.metrics import roc_auc_score, accuracy_score
auc_score = roc_auc_score(y_val, y_val_pred)
acc = accuracy_score(y_val, y_val_pred)
print(f&#39;auc_score: {auc_score}, acc: {acc}&#39;)</code></pre>
<h4 id="▪️-회귀-rmse-r2_score">▪️ 회귀: rmse, r2_score</h4>
<ul>
<li><strong>RSEM</strong>: 예측값과 실제값 사이 오차의 평균적 크기를 나타냄
값이 <strong>낮을 수록 안정적</strong></li>
<li><strong>R²(결정계수)</strong>: <strong>최대 1.0</strong>으로, 1에 가까울수록 성능이 좋음</li>
</ul>
<pre><code class="language-python">from sklearn.metrics import root_mean_squared_error, r2_score
rmse = root_mean_squared_error(y_val, y_val_pred)
r2 = r2_score(y_val, y_val_pred)
print(rmse, r2)</code></pre>
<h3 id="6-결과-저장">6. 결과 저장</h3>
<pre><code class="language-python">y_pred = model.predict(X_test)
result = pd.DataFrame(y_pred, columns=[&#39;pred&#39;])
result.to_csv(&#39;result.csv&#39;, index=False)</code></pre>
<h3 id="7-생성-결과-확인">7. 생성 결과 확인</h3>
<pre><code class="language-python">result = pd.read_csv(&#39;result.csv&#39;)
print(result)</code></pre>
<h2 id="🦋-제-3유형15점-문제-2개3문항-통계적-가설-검정">🦋 제 3유형(<strong>15점, 문제 2개(3문항)</strong>): 통계적 가설 검정</h2>
<h4 id="▪️-상관계수-dfcorr">▪️ 상관계수: df.corr()</h4>
<pre><code class="language-python">correlations = df.corr(numeric_only=True)[&#39;Traget&#39;].drop(&#39;Traget&#39;) # 자기자신 제외

# 가장 높은 상관계수와 변수 이름
max_corr_var = correlations.abs().idxmax()
max_corr_value = correlations[max_corr_var]

print(f&quot;📌 Target과 가장 선형관계가 큰 변수: {max_corr_var}&quot;)
print(f&quot;🔢 상관계수: {max_corr_value:.3f}&quot;)</code></pre>
<h4 id="▪️-f-검정f-test-두-집단의-분산이-같은가">▪️ F-검정(F-test): 두 집단의 분산이 같은가</h4>
<p>$$
F = \frac{s_1^2}{s_2^2}
$$</p>
<ul>
<li>$s_1^2$ : 분산이 더 큰 쪽 (분모가 작게 되면 F 값이 커져서 유의성이 높아짐)</li>
<li>$s_2^2$ : 분산이 더 작은 쪽</li>
</ul>
<p>👉 이 값은 <strong>F분포</strong>를 따름 (자유도는 <code>각 집단의 표본 수 – 1</code>)</p>
<ul>
<li>귀무가설(H₀) 두 집단의 분산은 같다: <code>σ₁² = σ₂²</code></li>
<li>대립가설(H₁) 두 집단의 분산은 다르다: <code>σ₁² ≠ σ₂²</code></li>
</ul>
<pre><code class="language-python">var1 = group1.var()
var2 = group2.var()

# 데이터의 개수 -1 = 자유도
dof_1 = len(group1) -1
dof_2 = len(group2) -1
print(dof_1, dof_2) # 51 63 → group2: 분자, group1: 분모

f_stat = var2/var1
print(round(f_stat,3))</code></pre>
<h4 id="▪️-분산-추정량sample-variance">▪️ 분산 추정량(Sample Variance)</h4>
<p>$$
s^2 = \frac{1}{n - 1} \sum (x_i - \bar{x})^2
$$  </p>
<ul>
<li>$n$: 표본의 크기</li>
<li>$x_i$: i번째 데이터 값</li>
<li>$\bar{x}$: 표본 평균</li>
</ul>
<h4 id="▪️-합동-분산-추정량-pooled-variance--등분산일-때-가능">▪️ 합동 분산 추정량 (Pooled Variance) : 등분산일 때 가능</h4>
<p>$$
s_p^2 = \frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2}
$$</p>
<ul>
<li>$s_1^2$, $s_2^2$: 두 집단의 표본 분산</li>
<li>$n_1$, $n_2$: 각 집단의 표본 수</li>
</ul>
<pre><code class="language-python">var1 = group1.var()
var2 = group2.var()
n1 = len(group1)
n2 = len(group2)

pooled_var = ((n1-1)*var1 + (n2-1)*var2) / (n1+n2-2)
print(round(pooled_var, 3)) </code></pre>
<h4 id="▪️-t-검정t-test">▪️ t-검정(t-test)</h4>
<p>$$
t = \frac{\bar{x}_1 - \bar{x}_2}{s_p \cdot \sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}
$$</p>
<pre><code class="language-python">mean1 = group1.mean()
mean2 = group2.mean()

t_stat = (mean1 - mean2) / np.sqrt(pooled_var * (1/n1 + 1/n2))</code></pre>
<ul>
<li>독립표본 → <code>ttest_ind()</code></li>
<li>대응표본 → <code>ttest_rel()</code></li>
<li>원샘플 → <code>ttest_1samp()</code></li>
<li>한표본 → </li>
</ul>
<h4 id="▪️-p-value유의확률">▪️ p-value(유의확률)</h4>
<ul>
<li>$p &lt; 0.05$: 유의수준 5% → Significant(유의함)</li>
<li>$p \geq 0.05$: Not Significant</li>
<li><code>model.pvalues.max()</code></li>
</ul>
<pre><code class="language-python">from scipy import stats 

ttest_result = stats.ttest_ind(group1, group2, equal_var=True)</code></pre>
<h4 id="▪️-오즈비odds-ratio">▪️ 오즈비(Odds Ratio):</h4>
<p>어떤 사건이 발생할 확률과 발생하지 않을 확률의 비율을 비교하는 값이다.</p>
<pre><code class="language-python">import numpy as np
coef = model.params[&#39;age&#39;]
# 오즈비 (odds ratio) = exp(회귀계수)
print(np.exp(coef))</code></pre>
<p>&quot;오즈비가 몇 배로 변화하는가?&quot; → 오즈비는 계수의 지수함수:
  $$
  \text{오즈비} = e^{\beta}
  $$</p>
<p>5단위로 증가하면:
  $$
  \text{변화한 오즈비} = e^{\beta \times 5}
  $$</p>
<ul>
<li>odds_ratio &gt; 1: 확률이 증가</li>
<li>odds_ratio &lt; 1: 확률이 감소</li>
<li>odds_ratio ≈ 1: 영향 거의 없음</li>
</ul>
<h4 id="▪️-잔차-이탈도residual-deviance-deviance">▪️ 잔차 이탈도(residual deviance): .deviance</h4>
<pre><code class="language-python">residual_deviance = -2 * model.llf
                  = model.deviance</code></pre>
<h4 id="▪️-로짓-우도값log-likelihood-of-the-model-llf">▪️ 로짓 우도값(Log-Likelihood of the model: .llf</h4>
<pre><code class="language-python">print(model.llf)</code></pre>
<hr>
<h2 id="선형-회귀-모델">선형 회귀 모델</h2>
<h3 id="회귀-계수regression-coefficient">회귀 계수(Regression Coefficient)</h3>
<p>회귀 계수는 <strong>각 독립변수가 종속변수에 미치는 영향력의 크기</strong>를 나타낸다.</p>
<p>$$
\text{PIQ} = \beta_0 + \beta_1 \cdot \text{Brain} + \beta_2 \cdot \text{Height}
$$</p>
<ul>
<li><code>β₀</code>: 상수항 (절편)</li>
<li><code>β₁</code>: Brain의 회귀 계수</li>
<li><code>β₂</code>: Height의 회귀 계수</li>
</ul>
<h4 id="의미">의미:</h4>
<ul>
<li><code>β₁ = 1.2</code>이면 → Brain 값이 <strong>1 단위 증가할 때</strong>, PIQ는 <strong>평균적으로 1.2 증가</strong>.</li>
<li><code>β₂ = -3.5</code>이면 → Height가 1 증가하면 PIQ는 평균적으로 3.5 감소.</li>
</ul>
<h3 id="상수항constant-or-intercept-추가">상수항(constant or intercept) 추가</h3>
<h4 id="📌-상수항이-없으면">📌 상수항이 없으면:</h4>
<p>모델이 <code>(0, 0)</code>을 반드시 지나야 한다는 제약이 생긴다. 즉,
$$
\text{PIQ} = \beta_1 \cdot \text{Brain} + \beta_2 \cdot \text{Height}
$$
→ 독립변수가 모두 0일 때 종속변수도 무조건 0이어야 함.</p>
<h4 id="📌-상수항을-추가하면">📌 상수항을 추가하면:</h4>
<p>$$
\text{PIQ} = \beta_0 + \beta_1 \cdot \text{Brain} + \beta_2 \cdot \text{Height}
$$</p>
<p>→ 데이터에 더 잘 맞는 <strong>유연한 모델</strong>을 만들 수 있고, 실제 데이터 분포에도 더 적합함.</p>
<ul>
<li><code>statsmodels</code>나 <code>scikit-learn</code>에서 회귀 분석할 때, <strong>반드시 상수항을 포함</strong>시키는 게 일반적.</li>
<li><code>statsmodels</code>는 기본적으로 <strong>상수항을 포함하지 않기 때문에</strong>, <code>sm.add_constant(X)</code>로 <strong>명시적으로 추가</strong>해줘야 함.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[🐧 Pandas: Column Reference]]></title>
            <link>https://velog.io/@m_ngyeong/Pandas-Column-Reference</link>
            <guid>https://velog.io/@m_ngyeong/Pandas-Column-Reference</guid>
            <pubDate>Sat, 14 Jun 2025 05:49:53 GMT</pubDate>
            <description><![CDATA[<h1 id="🐧-pandas-column-reference">🐧 Pandas: Column Reference</h1>
<hr>
<h2 id="df컬럼명--vs-df컬럼명"><code>df[&#39;컬럼명&#39;]</code>  vs <code>df.컬럼명</code></h2>
<p><strong>둘 다 컬럼의 값을 반환한다.</strong></p>
<table>
<thead>
<tr>
<th>항목</th>
<th><code>df[&#39;컬럼명&#39;]</code></th>
<th><code>df.컬럼명</code></th>
</tr>
</thead>
<tbody><tr>
<td>✅ 사용 범위</td>
<td><strong>모든 컬럼 이름</strong> 사용 가능</td>
<td><strong>파이썬 변수 이름 규칙</strong>만 가능</td>
</tr>
<tr>
<td>❌ 제약 조건</td>
<td>없음</td>
<td>컬럼명이 공백, 숫자 시작, 특수기호 포함이면 불가</td>
</tr>
<tr>
<td>💥 충돌 위험</td>
<td>없음</td>
<td><code>df.columns</code> 같은 속성과 충돌 가능</td>
</tr>
<tr>
<td>📌 추천 용도</td>
<td><strong>모든 상황에서 안정적</strong></td>
<td>코드 짧고 깔끔하게 쓸 때 유용</td>
</tr>
</tbody></table>
<h3 id="📌-예시-이런-경우는-df컬럼명만-가능">📌 예시: 이런 경우는 df[&#39;컬럼명&#39;]만 가능</h3>
<pre><code class="language-python">df[&#39;Credit Limit&#39;]        # O (공백 있음)
df[&#39;123Column&#39;]           # O (숫자로 시작)
df[&#39;class&#39;]               # O (&#39;class&#39;는 파이썬 예약어)</code></pre>
<pre><code class="language-python">df.Credit Limit           # ❌ 오류: 공백 있음
df.123Column              # ❌ 오류: 숫자로 시작
df.class                  # ❌ 오류: 예약어 충돌</code></pre>
<h3 id="✅-결론">✅ 결론</h3>
<table>
<thead>
<tr>
<th>상황</th>
<th>추천 방식</th>
</tr>
</thead>
<tbody><tr>
<td>일반적으로</td>
<td><code>df[&#39;컬럼명&#39;]</code> ← 더 <strong>안정적</strong>하고 <strong>범용적</strong></td>
</tr>
<tr>
<td>짧고 간단한 컬럼명 쓸 때만</td>
<td><code>df.컬럼명</code> 가능</td>
</tr>
</tbody></table>
]]></description>
        </item>
        <item>
            <title><![CDATA[Pandas: Tutorial 2️⃣]]></title>
            <link>https://velog.io/@m_ngyeong/Pandas-Tutorial-2</link>
            <guid>https://velog.io/@m_ngyeong/Pandas-Tutorial-2</guid>
            <pubDate>Wed, 28 May 2025 09:02:26 GMT</pubDate>
            <description><![CDATA[<h1 id="🐧-pandas-tutorial">🐧 Pandas: Tutorial</h1>
<hr>
<h2 id="🔸-filtering-data">🔸 Filtering Data</h2>
<h3 id="데이터-불러오기">데이터 불러오기</h3>
<pre><code class="language-python">https://github.com/justmarkham/DAT8/blob/master/data/chipotle.tsv
import pandas as pd

data_url = &#39;https://raw.githubusercontent.com/Datamanim/pandas/main/chipo.csv&#39;
df = pd.read_csv(data_url)</code></pre>
<hr>
<h3 id="loc조건">.loc[조건]</h3>
<pre><code class="language-python"># 식당데이터 : 
print(&#39;🍕 quantity 값이 3인 데이터 상위 5개 출력:&#39;)
print(df.loc[df[&#39;quantity&#39;]==3].head())</code></pre>
<ul>
<li><code>df[&#39;quantity&#39;]==3</code> : <code>quantity</code>라는 열의 값이 3과 같은 비교하여 <code>True/False</code> 중에 반환.</li>
<li><code>df.loc[조건]</code> : <code>.loc[]</code>는 조건에 맞는 행들을 선택, <code>quantity == 3</code>인 행들만 선택</li>
<li><code>.head()</code> : 상위 5개 행만 보여주는 함수.
<code>.head(3)</code>이면 상위 3개, <code>.head(10)</code>이면 10개.<pre><code>🍕 quantity 값이 3인 데이터 상위 5개 출력:
   order_id  quantity          item_name                                 choice_description item_price
409       178         3       Chicken Bowl  [[Fresh Tomato Salsa (Mild), Tomatillo-Green C...    $32.94 
445       193         3               Bowl  [Braised Carnitas, Pinto Beans, [Sour Cream, C...    $22.20 
689       284         3  Canned Soft Drink                                        [Diet Coke]     $3.75 
818       338         3      Bottled Water                                                NaN     $3.27 
850       350         3  Canned Soft Drink                                           [Sprite]     $3.75 </code></pre></li>
</ul>
<hr>
<h3 id="reset_index-인덱스-재정렬">.reset_index(): 인덱스 재정렬</h3>
<pre><code class="language-python">print(&#39;🍕 quantity 값이 3인 데이터 상위 5개를 출력히는데 인덱스를 0부터 시작하게 재정의:&#39;)
print(df.loc[df[&#39;quantity&#39;]==3].head().reset_index(drop=True))</code></pre>
<ul>
<li><code>.reset_index()</code> : <ul>
<li><strong>기존</strong>의 인덱스를 <strong>새로운 열</strong>로 이동시킴</li>
<li>새로운 <strong>0부터 시작</strong>하는 인덱스를 생성</li>
</ul>
</li>
<li><code>.reset_index(drop=True)</code>:<ul>
<li>기존 인덱스를 완전히 버림</li>
<li>0부터 다시 매긴 새로운 인덱스만 사용</li>
<li><strong>👉 기존 인덱스를 열로 보존하지 않음</strong></li>
</ul>
</li>
</ul>
<pre><code>🍕 quantity 값이 3인 데이터 상위 5개를 출력히는데 인덱스를 0부터 시작하게 재정의:
   order_id  quantity          item_name                                 choice_description item_price
0       178         3       Chicken Bowl  [[Fresh Tomato Salsa (Mild), Tomatillo-Green C...    $32.94 
1       193         3               Bowl  [Braised Carnitas, Pinto Beans, [Sour Cream, C...    $22.20 
2       284         3  Canned Soft Drink                                        [Diet Coke]     $3.75 
3       338         3      Bottled Water                                                NaN     $3.27 
4       350         3  Canned Soft Drink                                           [Sprite]     $3.75 </code></pre><hr>
<h3 id="새로운-데이터-프레임-정의">새로운 데이터 프레임 정의</h3>
<pre><code class="language-python">print(&#39;🆕 quantity, item_price의 컬럼으로 구성된 새로운 데이터 프레임을 정의:&#39;)
print(df[[&#39;quantity&#39;, &#39;item_price&#39;]])</code></pre>
<pre><code>🆕 quantity, item_price의 컬럼으로 구성된 새로운 데이터 프레임을 정의:
      quantity item_price
0            1     $2.39 
1            1     $3.39 
2            1     $3.39 
3            1     $2.39 
4            2    $16.98 
...        ...        ...
4617         1    $11.75 
4618         1    $11.75 
4619         1    $11.25 
4620         1     $8.75 
4621         1     $8.75 

[4622 rows x 2 columns]</code></pre><blockquote>
<p>❓ 왜 <code>df[&#39;quantity&#39;, &#39;item_price&#39;]</code> 이렇게 쓰면 안되나요?
이건 Pandas 입장에선 튜플 하나를 인덱싱한 것처럼 해석된다. 띠라서 <code>df[[&#39;quantity&#39;, &#39;item_price&#39;]]</code>처럼 <strong>대괄호 2개</strong>를 작성해야만 <strong>컬럼 두 개를 선택하라는 의미</strong>로 해석된다.</p>
</blockquote>
<table>
<thead>
<tr>
<th>표현</th>
<th>의미</th>
<th>동작 여부</th>
</tr>
</thead>
<tbody><tr>
<td><code>df[&#39;quantity&#39;]</code></td>
<td>하나의 컬럼 (시리즈 반환)</td>
<td>✅</td>
</tr>
<tr>
<td><code>df[[&#39;quantity&#39;]]</code></td>
<td>하나의 컬럼 (데이터프레임 반환)</td>
<td>✅</td>
</tr>
<tr>
<td><code>df[[&#39;quantity&#39;, &#39;item_price&#39;]]</code></td>
<td>두 개 이상의 컬럼 선택</td>
<td>✅</td>
</tr>
<tr>
<td><code>df[&#39;quantity&#39;, &#39;item_price&#39;]</code></td>
<td>튜플 키 → 해당 이름 가진 열을 찾음 (오류)</td>
<td>❌ 오류</td>
</tr>
</tbody></table>
<hr>
<h3 id="astype--type-변경">.astype() : type 변경</h3>
<pre><code class="language-python">print(&#39;💵 item_price에 $를 제거하고 float 타입으로 변경하여 item_price_float에 저장:&#39;)
df[&#39;item_price_float&#39;] = df[&#39;item_price&#39;].str.replace(&#39;$&#39;, &#39;&#39;, regex=False).astype(float)
print(df[&#39;item_price_float&#39;].head())</code></pre>
<ul>
<li><code>.str.replace(&#39;$&#39;, &#39;&#39;, regex=False)</code> → <code>$</code> 기호를 없앰 <ul>
<li><code>.str.replace()</code>: Pandas는 기본적으로 pat을 <strong>정규표현식(Regex)</strong>으로 인식하여, <code>regex=True</code>가 기본값</li>
<li><code>$</code>는 <strong>&quot;문장의 끝&quot;</strong>을 의미하는 메타문자로 <code>regex=False</code>를 작성해 문자의 의미를 없애줌</li>
</ul>
</li>
<li><code>.astype(float)</code> → 문자열 &quot;3.50&quot; → 실수 3.50으로 변환<pre><code>💵 item_price에 $를 제거하고 float 타입으로 변경하여 item_price_float에 저장:
0     2.39
1     3.39
2     3.39
3     2.39
4    16.98
Name: item_price_float, dtype: float64</code></pre></li>
</ul>
<hr>
<h3 id="🧐">🧐</h3>
<pre><code class="language-python">print(&#39;🍗 item_name이 &quot;Chicken Salad Bowl&quot;인 것과 item_price_float가 9 이하인 것을 찾아라:&#39;)
filtered_df = df.loc[(df.item_name == &quot;Chicken Salad Bowl&quot;) &amp; (df.item_price_float &lt;= 9)]
print(&quot;☑️ 조건에 맞는 상위 5개: &quot;)
print(filtered_df.head())
print(&#39;☑️ 전체 개수:&#39;, len(filtered_df))</code></pre>
<pre><code>🍗 item_name이 &quot;Chicken Salad Bowl&quot;인 것과 item_price_float가 9 이하인 것을 찾아라:
☑️ 조건에 맞는 상위 5개: 
     order_id  quantity           item_name                                 choice_description item_price  item_price_float
44         20         1  Chicken Salad Bowl  [Fresh Tomato Salsa, [Fajita Vegetables, Pinto...     $8.75               8.75
256       111         1  Chicken Salad Bowl  [Fresh Tomato Salsa, [Fajita Vegetables, Rice,...     $8.75               8.75
526       220         1  Chicken Salad Bowl  [Roasted Chili Corn Salsa, [Black Beans, Sour ...     $8.75               8.75
528       221         1  Chicken Salad Bowl  [Tomatillo Green Chili Salsa, [Fajita Vegetabl...     $8.75               8.75
529       221         1  Chicken Salad Bowl  [Tomatillo Green Chili Salsa, [Fajita Vegetabl...     $8.75               8.75
☑️ 전체 개수: 56</code></pre><hr>
<h3 id="sort_values-오름차순-정렬">.sort_values(): 오름차순 정렬</h3>
<pre><code class="language-python">print(&#39;💵 item_price_float를 오름차순으로 정리하고 index를 초기화:&#39;)
print(df.sort_values(&#39;item_price_float&#39;).reset_index(drop=True).head())</code></pre>
<pre><code>💵 item_price_float를 오름차순으로 정리하고 index를 초기화:
   order_id  quantity      item_name choice_description item_price  item_price_float
0       471         1  Bottled Water                NaN     $1.09               1.09
1       338         1    Canned Soda        [Coca Cola]     $1.09               1.09
2      1575         1    Canned Soda       [Dr. Pepper]     $1.09               1.09
3        47         1    Canned Soda       [Dr. Pepper]     $1.09               1.09
4      1014         1    Canned Soda        [Coca Cola]     $1.09               1.09</code></pre><hr>
<h3 id="ascendingfalse-내림차순">ascending=False: 내림차순</h3>
<pre><code class="language-python">print(&#39;💵 item_price_float를 내림차순으로 정리하고 index를 초기화:&#39;)
print(df.sort_values(&#39;item_price_float&#39;, ascending=False).reset_index(drop=True).head())</code></pre>
<pre><code>💵 item_price_float를 내림차순으로 정리하고 index를 초기화:
   order_id  quantity                     item_name                                 choice_description item_price  item_price_float
0      1443        15  Chips and Fresh Tomato Salsa                                                NaN    $44.25              44.25
1      1398         3                 Carnitas Bowl  [Roasted Chili Corn Salsa, [Fajita Vegetables,...    $35.25              35.25
2       511         4               Chicken Burrito  [Fresh Tomato Salsa, [Fajita Vegetables, Rice,...    $35.00              35.00
3      1443         4               Chicken Burrito  [Fresh Tomato Salsa, [Rice, Black Beans, Chees...    $35.00              35.00
4      1443         3                Veggie Burrito  [Fresh Tomato Salsa, [Fajita Vegetables, Rice,...    $33.75              33.75</code></pre><hr>
<h3 id="strcontains-해당-문제열-포함-여부">.str.contains(): 해당 문제열 포함 여부</h3>
<pre><code class="language-python">print(&#39;🍪 item_name에 &quot;Chips&quot;가 포함되는 상위 5개 데이터 추출:&#39;)
print(df.loc[df.item_name.str.contains(&#39;Chips&#39;)].head())</code></pre>
<ul>
<li><code>.str.contains(&#39;Chips&#39;)</code> → 문자열 &quot;Chips&quot;가 포함되어 있는지 여부를 <code>True/False</code>로 반환</li>
<li><code>str.contains(&#39;chips&#39;, case=False)</code>: <strong>대소문자 무시</strong></li>
<li><code>str.contains(&#39;Chips&#39;, regex=False)</code>: <strong>정규표현식 사용 안함</strong><pre><code>🍪 item_name에 &quot;Chips&quot;가 포함되는 상위 5개 데이터 추출:
  order_id  quantity                              item_name choice_description item_price  item_price_float
0          1         1           Chips and Fresh Tomato Salsa                NaN     $2.39               2.39
3          1         1  Chips and Tomatillo-Green Chili Salsa                NaN     $2.39               2.39
6          3         1                          Side of Chips                NaN     $1.69               1.69
10         5         1                    Chips and Guacamole                NaN     $4.45               4.45
14         7         1                    Chips and Guacamole                NaN     $4.45               4.45</code></pre></li>
</ul>
<hr>
<h3 id="🥗-둘-중-하나만-포함">🥗 둘 중 하나만 포함</h3>
<pre><code class="language-python">print(&#39;🥗 item_name에 &quot;Steak Salad&quot; 또는 &quot;Bowl&quot;가 포함되는 데이터 추출:&#39;)
answer = df.loc[(df.item_name == &#39;Steak Salad&#39;) | (df.item_name == &#39;Bowl&#39;)]
print(answer)</code></pre>
<pre><code>      order_id  quantity  ... item_price item_price_float
445        193         3  ...    $22.20             22.20
664        276         1  ...     $8.99              8.99
673        279         1  ...     $7.40              7.40
752        311         1  ...     $8.99              8.99
893        369         1  ...     $8.99              8.99
3502      1406         1  ...     $8.69              8.69

[6 rows x 6 columns]</code></pre><hr>
<h3 id="drop_duplicates-중복행-제거후-첫번째-케이스-출력">.drop_duplicates(&#39;&#39;): 중복행 제거후 첫번째 케이스 출력</h3>
<pre><code class="language-python">print(&#39;🥗 item_name에 &quot;Steak Salad&quot; 또는 &quot;Bowl&quot;가 포함되는 데이터 추출:&#39;)
print(answer.drop_duplicates(&#39;item_name&#39;))</code></pre>
<pre><code>     order_id  quantity  ... item_price item_price_float
445       193         3  ...    $22.20             22.20
664       276         1  ...     $8.99              8.99</code></pre><hr>
<h3 id="drop_duplicates-keeplast-중복행-제거후-마지막-케이스-출력">.drop_duplicates(&#39;&#39;, keep=&#39;last&#39;): 중복행 제거후 마지막 케이스 출력</h3>
<pre><code class="language-python">print(&#39;🥗 item_name에 &quot;Steak Salad&quot; 또는 &quot;Bowl&quot;가 포함되는 데이터 추출:&#39;)
print(answer.drop_duplicates(&#39;item_name&#39;, keep=&#39;last&#39;))</code></pre>
<pre><code>      order_id  quantity  ... item_price item_price_float
673        279         1  ...     $7.40              7.40
3502      1406         1  ...     $8.69              8.69</code></pre><hr>
<h3 id="dfiloc2--짝수열">df.iloc[:,::2] : 짝수열</h3>
<pre><code class="language-python">print(&quot;😈 짝수번째 컬럼만 출력:&quot;)
print(df.iloc[:,::2].head())</code></pre>
<ul>
<li><strong><code>slicing[start : end : step]</code></strong><ul>
<li><code>::2</code>는 처음부터 끝까지 2칸씩 건너뛰기
(인덱스: 0, 2, 4, 6, ...)</li>
</ul>
</li>
<li><code>[:,::2]</code>:<ul>
<li><code>:</code>: 행 위치, 모든 행 선택</li>
<li><code>::2</code>: 열 위치, 열 인덱스를 2칸씩 건너뛰며 선택</li>
</ul>
</li>
<li><code>df.iloc[::2, :]</code>:    모든 열에서 <strong>행 인덱스를 2칸씩 건너뛰며</strong> 선택<pre><code>😈 짝수번째 컬럼만 출력:
 order_id                              item_name item_price
0         1           Chips and Fresh Tomato Salsa     $2.39 
1         1                                   Izze     $3.39 
2         1                       Nantucket Nectar     $3.39 
3         1  Chips and Tomatillo-Green Chili Salsa     $2.39 
4         2                           Chicken Bowl    $16.98 </code></pre></li>
</ul>
<hr>
</br>

<blockquote>
<p>참고, <a href="https://www.datamanim.com/dataset/99_pandas/pandasMain.html#filtering-sorting">https://www.datamanim.com/dataset/99_pandas/pandasMain.html#filtering-sorting</a></p>
</blockquote>
]]></description>
        </item>
        <item>
            <title><![CDATA[Pandas: Tutorial 1️⃣]]></title>
            <link>https://velog.io/@m_ngyeong/Pandas-Tutorial-1</link>
            <guid>https://velog.io/@m_ngyeong/Pandas-Tutorial-1</guid>
            <pubDate>Tue, 27 May 2025 08:56:17 GMT</pubDate>
            <description><![CDATA[<h1 id="🐧-pandas-tutorial">🐧 Pandas: Tutorial</h1>
<hr>
<h2 id="🔸-pandas-선언">🔸 Pandas 선언</h2>
<pre><code class="language-python">import pandas as pd</code></pre>
<h2 id="🔸-csv-파일-읽어오기">🔸 CSV 파일 읽어오기</h2>
<pre><code class="language-python"># 파일 경로 지정
titanic_train = &#39;./titanic/train.csv&#39;
titanic_test = &#39;./titanic/test.csv&#39;

# CSV 파일 읽어오기
df_train = pd.read_csv(titanic_train)
df_test = pd.read_csv(titanic_test)</code></pre>
<h4 id="만약-데이터에-한글이-포함되어-있을-경우-encodingeuc-kr">만약 데이터에 한글이 포함되어 있을 경우: <code>encoding=&#39;euc-kr&#39;</code></h4>
<pre><code>DataUrl = &#39;https://raw.githubusercontent.com/Datamanim/pandas/main/Jeju.csv&#39;
df = pd.read_csv(DataUrl,encoding=&#39;euc-kr&#39;)</code></pre><h2 id="🔸-data-구조-확인">🔸 Data 구조 확인</h2>
<h3 id="type-데이터-로드"><code>type()</code>: 데이터 로드</h3>
<pre><code class="language-python"># 데이터 확인
print(type(df_train), type(df_test))</code></pre>
<pre><code class="language-zsh">&lt;class &#39;pandas.core.frame.DataFrame&#39;&gt;</code></pre>
<hr>
<h3 id="head-상위-행-5개-출력"><code>.head()</code>: 상위 행 5개 출력</h3>
<pre><code class="language-python">print(df_train.head())  
print(df_test.head())</code></pre>
<pre><code> PassengerId  Survived  Pclass                                               Name     Sex   Age  SibSp  Parch            Ticket     Fare Cabin Embarked
0            1         0       3                            Braund, Mr. Owen Harris    male  22.0      1      0         A/5 21171   7.2500   NaN        S
1            2         1       1  Cumings, Mrs. John Bradley (Florence Briggs Th...  female  38.0      1      0          PC 17599  71.2833   C85        C
2            3         1       3                             Heikkinen, Miss. Laina  female  26.0      0      0  STON/O2. 3101282   7.9250   NaN        S
3            4         1       1       Futrelle, Mrs. Jacques Heath (Lily May Peel)  female  35.0      1      0            113803  53.1000  C123        S
4            5         0       3                           Allen, Mr. William Henry    male  35.0      0      0            373450   8.0500   NaN        S
   PassengerId  Pclass                                          Name     Sex   Age  SibSp  Parch   Ticket     Fare Cabin Embarked
0          892       3                              Kelly, Mr. James    male  34.5      0      0   330911   7.8292   NaN        Q
1          893       3              Wilkes, Mrs. James (Ellen Needs)  female  47.0      1      0   363272   7.0000   NaN        S
2          894       2                     Myles, Mr. Thomas Francis    male  62.0      0      0   240276   9.6875   NaN        Q
3          895       3                              Wirz, Mr. Albert    male  27.0      0      0   315154   8.6625   NaN        S
4          896       3  Hirvonen, Mrs. Alexander (Helga E Lindqvist)  female  22.0      1      1  3101298  12.2875   NaN        S</code></pre><hr>
<h3 id="tail-하위-행-5개-출력"><code>.tail()</code>: 하위 행 5개 출력</h3>
<pre><code class="language-python">print(df_train.tail())
print(df_test.tail(2))</code></pre>
<pre><code>     PassengerId  Survived  Pclass                                      Name     Sex   Age  SibSp  Parch      Ticket   Fare Cabin Embarked
886          887         0       2                     Montvila, Rev. Juozas    male  27.0      0      0      211536  13.00   NaN        S
887          888         1       1              Graham, Miss. Margaret Edith  female  19.0      0      0      112053  30.00   B42        S
888          889         0       3  Johnston, Miss. Catherine Helen &quot;Carrie&quot;  female   NaN      1      2  W./C. 6607  23.45   NaN        S
889          890         1       1                     Behr, Mr. Karl Howell    male  26.0      0      0      111369  30.00  C148        C
890          891         0       3                       Dooley, Mr. Patrick    male  32.0      0      0      370376   7.75   NaN        Q
     PassengerId  Pclass                      Name   Sex  Age  SibSp  Parch  Ticket     Fare Cabin Embarked
416         1308       3       Ware, Mr. Frederick  male  NaN      0      0  359309   8.0500   NaN        S
417         1309       3  Peter, Master. Michael J  male  NaN      1      1    2668  22.3583   NaN        C</code></pre><hr>
<h3 id="shape-행-열-갯수-출력"><code>.shape</code>: 행, 열 갯수 출력</h3>
<pre><code class="language-python">print(f&#39;🛳️ train(행,열): {df_train.shape}&#39;)
print(f&#39;⚓️ test 행: {df_test.shape[0]}, test 열: {df_test.shape[1]}&#39;)</code></pre>
<pre><code>🛳️ train(행,열): (891, 12)
⚓️ test 행: 418, test 열: 11</code></pre><hr>
<h3 id="cloumns-전체-컬럼명-확인">.cloumns: 전체 컬럼명 확인</h3>
<pre><code class="language-python">print(f&#39;🛳️ Train columns:\n{df_train.columns}&#39;)
print(f&#39;⚓️ Test columns:\n{df_test.columns}&#39;)</code></pre>
<pre><code>🛳️ Train columns:
Index([&#39;PassengerId&#39;, &#39;Survived&#39;, &#39;Pclass&#39;, &#39;Name&#39;, &#39;Sex&#39;, &#39;Age&#39;, &#39;SibSp&#39;,
       &#39;Parch&#39;, &#39;Ticket&#39;, &#39;Fare&#39;, &#39;Cabin&#39;, &#39;Embarked&#39;],
      dtype=&#39;object&#39;)
⚓️ Test columns:
Index([&#39;PassengerId&#39;, &#39;Pclass&#39;, &#39;Name&#39;, &#39;Sex&#39;, &#39;Age&#39;, &#39;SibSp&#39;, &#39;Parch&#39;,
       &#39;Ticket&#39;, &#39;Fare&#39;, &#39;Cabin&#39;, &#39;Embarked&#39;],
      dtype=&#39;object&#39;)</code></pre><hr>
<h3 id="index-인덱스-구성-확인">.index: 인덱스 구성 확인</h3>
<pre><code class="language-python">print(f&#39;🛳️ trian: {df_train.index}&#39;)
print(f&#39;⚓️ test: {df_test.index}&#39;)</code></pre>
<pre><code>🛳️ trian: RangeIndex(start=0, stop=891, step=1)
⚓️ test: RangeIndex(start=0, stop=418, step=1</code></pre><hr>
<h3 id="info-각-열의-데이터-수-데이터-타입-확인">.info(): 각 열의 데이터 수, 데이터 타입 확인</h3>
<pre><code class="language-python">print(&#39;🛳️ trian:&#39;)
print(df_train.info())

print(&#39;⚓️ test:&#39;)
print(df_test.info())</code></pre>
<pre><code>🛳️ trian:
&lt;class &#39;pandas.core.frame.DataFrame&#39;&gt;
RangeIndex: 891 entries, 0 to 890
Data columns (total 12 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   PassengerId  891 non-null    int64  
 1   Survived     891 non-null    int64  
 2   Pclass       891 non-null    int64  
 3   Name         891 non-null    object 
 4   Sex          891 non-null    object 
 5   Age          714 non-null    float64
 6   SibSp        891 non-null    int64  
 7   Parch        891 non-null    int64  
 8   Ticket       891 non-null    object 
 9   Fare         891 non-null    float64
 10  Cabin        204 non-null    object 
 11  Embarked     889 non-null    object 
dtypes: float64(2), int64(5), object(5)
memory usage: 83.7+ KB
None

⚓️ test:
&lt;class &#39;pandas.core.frame.DataFrame&#39;&gt;
RangeIndex: 418 entries, 0 to 417
Data columns (total 11 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   PassengerId  418 non-null    int64  
 1   Pclass       418 non-null    int64  
 2   Name         418 non-null    object 
 3   Sex          418 non-null    object 
 4   Age          332 non-null    float64
 5   SibSp        418 non-null    int64  
 6   Parch        418 non-null    int64  
 7   Ticket       418 non-null    object 
 8   Fare         417 non-null    float64
 9   Cabin        91 non-null     object 
 10  Embarked     418 non-null    object 
dtypes: float64(2), int64(4), object(5)
memory usage: 36.1+ KB
None</code></pre><hr>
<h3 id="dtype-선택한-열의-데이터-타입data-type을-반환">.dtype: 선택한 열의 <strong>데이터 타입(data type)</strong>을 반환</h3>
<pre><code class="language-python">print(f&#39;🛳️ train 4번쨰 행의 data type: {df_train.iloc[:,3].dtype}&#39;)
# df_train.columns
# Index([&#39;PassengerId&#39;, &#39;Survived&#39;, &#39;Pclass&#39;, &#39;Name&#39;, ...])</code></pre>
<pre><code>🛳️ train 4번쨰 행의 data type: object</code></pre><ul>
<li><code>df_train.iloc[:,3]</code>: <code>Name</code>열을 선택</li>
<li><code>.iloc</code>: 인덱스로 행/열을 선택하는 함수</li>
<li><code>[:,3]</code><ul>
<li><code>:</code> → 모든 행을 의미</li>
<li><code>3</code> → <strong>열 인덱스 3번 (네 번째 열)</strong>을 선택</li>
</ul>
</li>
<li><code>dtype(&#39;O&#39;/&#39;object&#39;)</code> → 문자열</li>
<li><code>dtype(&#39;int64&#39;)</code> → 정수</li>
<li><code>dtype(&#39;float64&#39;)</code> → 실수</li>
</ul>
<hr>
<h3 id="🔁-iloc-vs-loc">🔁 iloc vs loc</h3>
<table>
<thead>
<tr>
<th>항목</th>
<th><code>iloc</code>(= integer location)</th>
<th><code>loc</code></th>
</tr>
</thead>
<tbody><tr>
<td>의미</td>
<td><strong>index location</strong> (정수 기반 인덱싱)</td>
<td><strong>label location</strong> (레이블 기반 인덱싱)</td>
</tr>
<tr>
<td>기준</td>
<td>숫자 위치 (0, 1, 2...)</td>
<td>실제 인덱스 이름, 열 이름</td>
</tr>
<tr>
<td>사용 예시</td>
<td><code>df.iloc[0, 1]</code></td>
<td><code>df.loc[0, &#39;Name&#39;]</code></td>
</tr>
<tr>
<td></td>
<td><strong><code>.iloc[row_idx, col_idx]</code></strong></td>
<td></td>
</tr>
<tr>
<td>유용한 상황</td>
<td>위치로 접근할 때</td>
<td>이름 기준으로 접근할 때</td>
</tr>
</tbody></table>
<h4 id="✅-예제-데이터">✅ 예제 데이터</h4>
<pre><code class="language-python">import pandas as pd

data = {
    &#39;Name&#39;: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;],
    &#39;Age&#39;: [25, 30, 35],
}
df = pd.DataFrame(data, index=[100, 101, 102])
print(df)</code></pre>
<p>출력:</p>
<pre><code>      Name  Age
100  Alice   25
101    Bob   30
102 Charlie   35</code></pre><h4 id="🔹-iloc-예시-위치-기반">🔹 iloc 예시 (위치 기반)</h4>
<pre><code class="language-python">df.iloc[0, 0]   # 0행 0열 → &#39;Alice&#39;
df.iloc[2, 1]   # 2행 1열 → 35
df.iloc[:, 1]   # 전체 행, 1열 (Age 열) → [25, 30, 35]</code></pre>
<h4 id="🔹-loc-예시-레이블-기반">🔹 loc 예시 (레이블 기반)</h4>
<pre><code class="language-python">df.loc[100, &#39;Name&#39;]   # 인덱스 100 행, &#39;Name&#39; 열 → &#39;Alice&#39;
df.loc[102, &#39;Age&#39;]    # 인덱스 102 행, &#39;Age&#39; 열 → 35
df.loc[:, &#39;Name&#39;]     # 전체 행, &#39;Name&#39; 열 → [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;]</code></pre>
<hr>
<h3 id="수치형exclude범주형include-변수">수치형(exclude)/범주형(include) 변수</h3>
<ul>
<li><code>.select_dtypes(exclude[include]=object).columns</code><pre><code class="language-python">print(&#39;🛳️ train의 수치형 변수를 가진 행:&#39;)
print(df_train.select_dtypes(exclude=object).columns)
</code></pre>
</li>
</ul>
<p>print(&#39;⚓️ test의 범주형 변수를 가진 행:&#39;)
print(df_test.select_dtypes(include=object).columns)</p>
<pre><code></code></pre><p>🛳️ train의 수치형 변수를 가진 행:
Index([&#39;PassengerId&#39;, &#39;Survived&#39;, &#39;Pclass&#39;, &#39;Age&#39;, &#39;SibSp&#39;, &#39;Parch&#39;, &#39;Fare&#39;], dtype=&#39;object&#39;)</p>
<p>⚓️ test의 범주형 변수를 가진 행:
Index([&#39;Name&#39;, &#39;Sex&#39;, &#39;Ticket&#39;, &#39;Cabin&#39;, &#39;Embarked&#39;], dtype=&#39;object&#39;)</p>
<pre><code>---
### .isnull(): 결측치 파악
```python
print(f&#39;🛳️ train 결측치 갯수: \n{df_train.isnull().sum()}&#39;)
print(f&#39;⚓️ test 결측치 갯수: \n{df_test.isnull().sum()}&#39;)</code></pre><pre><code>🛳️ train 결측치 갯수: 
PassengerId      0
Survived         0
Pclass           0
Name             0
Sex              0
Age            177
SibSp            0
Parch            0
Ticket           0
Fare             0
Cabin          687
Embarked         2
dtype: int64

⚓️ test 결측치 갯수: 
PassengerId      0
Pclass           0
Name             0
Sex              0
Age             86
SibSp            0
Parch            0
Ticket           0
Fare             1
Cabin          327
Embarked         0
dtype: int64</code></pre><hr>
<h3 id="describe-수치형-변수의-분포사분위-평균-표준편차-최대--최소-확인">.describe(): 수치형 변수의 분포(사분위, 평균, 표준편차, 최대 , 최소) 확인</h3>
<pre><code class="language-python">print(&#39;🛳️ train describe:&#39;)
print(tabulate(df_train.describe(), headers=&#39;keys&#39;, tablefmt=&#39;pretty&#39;))

print(&#39;⚓️ test describe:&#39;)
print(tabulate(df_test.describe(), headers=&#39;keys&#39;, tablefmt=&#39;pretty&#39;))</code></pre>
<pre><code>🛳️ train describe:
+-------+-------------------+--------------------+--------------------+--------------------+--------------------+---------------------+--------------------+
|       |    PassengerId    |      Survived      |       Pclass       |        Age         |       SibSp        |        Parch        |        Fare        |
+-------+-------------------+--------------------+--------------------+--------------------+--------------------+---------------------+--------------------+
| count |       891.0       |       891.0        |       891.0        |       714.0        |       891.0        |        891.0        |       891.0        |
| mean  |       446.0       | 0.3838383838383838 | 2.308641975308642  | 29.69911764705882  | 0.5230078563411896 | 0.38159371492704824 | 32.204207968574636 |
|  std  | 257.3538420152301 | 0.4865924542648585 | 0.8360712409770513 | 14.526497332334044 | 1.1027434322934275 | 0.8060572211299559  |  49.6934285971809  |
|  min  |        1.0        |        0.0         |        1.0         |        0.42        |        0.0         |         0.0         |        0.0         |
|  25%  |       223.5       |        0.0         |        2.0         |       20.125       |        0.0         |         0.0         |       7.9104       |
|  50%  |       446.0       |        0.0         |        3.0         |        28.0        |        0.0         |         0.0         |      14.4542       |
|  75%  |       668.5       |        1.0         |        3.0         |        38.0        |        1.0         |         0.0         |        31.0        |
|  max  |       891.0       |        1.0         |        3.0         |        80.0        |        8.0         |         6.0         |      512.3292      |
+-------+-------------------+--------------------+--------------------+--------------------+--------------------+---------------------+--------------------+


⚓️ test describe:
+-------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
|       |    PassengerId     |       Pclass       |        Age         |       SibSp        |       Parch        |        Fare        |
+-------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
| count |       418.0        |       418.0        |       332.0        |       418.0        |       418.0        |       417.0        |
| mean  |       1100.5       | 2.2655502392344498 | 30.272590361445783 | 0.4473684210526316 | 0.3923444976076555 | 35.627188489208635 |
|  std  | 120.81045760473994 | 0.8418375519640519 | 14.18120923562442  | 0.8967595611217125 | 0.9814288785371684 | 55.90757617997383  |
|  min  |       892.0        |        1.0         |        0.17        |        0.0         |        0.0         |        0.0         |
|  25%  |       996.25       |        1.0         |        21.0        |        0.0         |        0.0         |       7.8958       |
|  50%  |       1100.5       |        3.0         |        27.0        |        0.0         |        0.0         |      14.4542       |
|  75%  |      1204.75       |        3.0         |        39.0        |        1.0         |        0.0         |        31.5        |
|  max  |       1309.0       |        3.0         |        76.0        |        8.0         |        9.0         |      512.3292      |
+-------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+</code></pre><hr>
<h3 id="🧐-name-컬럼에-해당하는-값들을-출력">🧐 Name 컬럼에 해당하는 값들을 출력</h3>
<pre><code class="language-python">print(&#39;🛳️ Names:&#39;)
print(df_train[&#39;Name&#39;])</code></pre>
<pre><code>🛳️ Names:
0                                Braund, Mr. Owen Harris
1      Cumings, Mrs. John Bradley (Florence Briggs Th...
2                                 Heikkinen, Miss. Laina
3           Futrelle, Mrs. Jacques Heath (Lily May Peel)
4                               Allen, Mr. William Henry
                             ...                        
886                                Montvila, Rev. Juozas
887                         Graham, Miss. Margaret Edith
888             Johnston, Miss. Catherine Helen &quot;Carrie&quot;
889                                Behr, Mr. Karl Howell
890                                  Dooley, Mr. Patrick
Name: Name, Length: 891, dtype: object</code></pre><hr>
<h3 id="quantile-4분위-범위iqr">.quantile(): 4분위 범위(IQR)</h3>
<pre><code class="language-python">print(f&#39;🛳️ Age IQR: {df_train[&#39;Age&#39;].quantile(0.75) - df_train[&#39;Age&#39;].quantile(0.25)}&#39;)</code></pre>
<pre><code>🛳️ Age IQR: 17.875</code></pre><hr>
<h3 id="nunique--unique-유일값-확인">.nunique() / .unique() :유일값 확인</h3>
<ul>
<li><code>.nunique()</code>: 유일값 갯수</li>
<li><code>.unique()</code>: 유일값에 해당하는 것 모두 출력<pre><code class="language-python">print(f&#39;🛳️ Cabin 유일값 갯수: {df_train.Cabin.nunique()}&#39;)
print(f&#39;🛳️ Cabin 유일값: {df_train.Cabin.unique()}&#39;)</code></pre>
<pre><code>🛳️ Cabin 유일값 갯수: 147
</code></pre></li>
</ul>
<p>🛳️ Cabin 유일값: [nan &#39;C85&#39; &#39;C123&#39; &#39;E46&#39; &#39;G6&#39; &#39;C103&#39; &#39;D56&#39; &#39;A6&#39; &#39;C23 C25 C27&#39; &#39;B78&#39; &#39;D33&#39;
 &#39;B30&#39; &#39;C52&#39; &#39;B28&#39; &#39;C83&#39; &#39;F33&#39; &#39;F G73&#39; &#39;E31&#39; &#39;A5&#39; &#39;D10 D12&#39; &#39;D26&#39; &#39;C110&#39;
 &#39;B58 B60&#39; &#39;E101&#39; &#39;F E69&#39; &#39;D47&#39; &#39;B86&#39; &#39;F2&#39; &#39;C2&#39; &#39;E33&#39; &#39;B19&#39; &#39;A7&#39; &#39;C49&#39;
 &#39;F4&#39; &#39;A32&#39; &#39;B4&#39; &#39;B80&#39; &#39;A31&#39; &#39;D36&#39; &#39;D15&#39; &#39;C93&#39; &#39;C78&#39; &#39;D35&#39; &#39;C87&#39; &#39;B77&#39;
 &#39;E67&#39; &#39;B94&#39; &#39;C125&#39; &#39;C99&#39; &#39;C118&#39; &#39;D7&#39; &#39;A19&#39; &#39;B49&#39; &#39;D&#39; &#39;C22 C26&#39; &#39;C106&#39;
 &#39;C65&#39; &#39;E36&#39; &#39;C54&#39; &#39;B57 B59 B63 B66&#39; &#39;C7&#39; &#39;E34&#39; &#39;C32&#39; &#39;B18&#39; &#39;C124&#39; &#39;C91&#39;
 &#39;E40&#39; &#39;T&#39; &#39;C128&#39; &#39;D37&#39; &#39;B35&#39; &#39;E50&#39; &#39;C82&#39; &#39;B96 B98&#39; &#39;E10&#39; &#39;E44&#39; &#39;A34&#39;
 &#39;C104&#39; &#39;C111&#39; &#39;C92&#39; &#39;E38&#39; &#39;D21&#39; &#39;E12&#39; &#39;E63&#39; &#39;A14&#39; &#39;B37&#39; &#39;C30&#39; &#39;D20&#39; &#39;B79&#39;
 &#39;E25&#39; &#39;D46&#39; &#39;B73&#39; &#39;C95&#39; &#39;B38&#39; &#39;B39&#39; &#39;B22&#39; &#39;C86&#39; &#39;C70&#39; &#39;A16&#39; &#39;C101&#39; &#39;C68&#39;
 &#39;A10&#39; &#39;E68&#39; &#39;B41&#39; &#39;A20&#39; &#39;D19&#39; &#39;D50&#39; &#39;D9&#39; &#39;A23&#39; &#39;B50&#39; &#39;A26&#39; &#39;D48&#39; &#39;E58&#39;
 &#39;C126&#39; &#39;B71&#39; &#39;B51 B53 B55&#39; &#39;D49&#39; &#39;B5&#39; &#39;B20&#39; &#39;F G63&#39; &#39;C62 C64&#39; &#39;E24&#39; &#39;C90&#39;
 &#39;C45&#39; &#39;E8&#39; &#39;B101&#39; &#39;D45&#39; &#39;C46&#39; &#39;D30&#39; &#39;E121&#39; &#39;D11&#39; &#39;E77&#39; &#39;F38&#39; &#39;B3&#39; &#39;D6&#39;
 &#39;B82 B84&#39; &#39;D17&#39; &#39;A36&#39; &#39;B102&#39; &#39;B69&#39; &#39;E49&#39; &#39;C47&#39; &#39;D28&#39; &#39;E17&#39; &#39;A24&#39; &#39;C50&#39;
 &#39;B42&#39; &#39;C148&#39;]</p>
<h2 id="">```</h2>
</br>

<blockquote>
<p>참고, <a href="https://www.datamanim.com/dataset/99_pandas/pandasMain.html#getting-knowing-data">https://www.datamanim.com/dataset/99_pandas/pandasMain.html#getting-knowing-data</a></p>
</blockquote>
]]></description>
        </item>
        <item>
            <title><![CDATA[Pandas: Intro]]></title>
            <link>https://velog.io/@m_ngyeong/Pandas-Intro</link>
            <guid>https://velog.io/@m_ngyeong/Pandas-Intro</guid>
            <pubDate>Thu, 22 May 2025 08:56:37 GMT</pubDate>
            <description><![CDATA[<h1 id="🐧-pandas-intro">🐧 Pandas: Intro</h1>
<p><strong>Pandas</strong>는 <strong>Python</strong>에서 데이터를 쉽게 다루고 분석할 수 있도록 도와주는 <strong>오픈 소스 라이브러리</strong>로 주로 <strong>표 형식의 데이터</strong>를 다룰 때 사용한다.</p>
<hr>
<h3 id="📦-pandas의-핵심-기능">📦 Pandas의 핵심 기능</h3>
<ul>
<li>데이터프레임(DataFrame)과 시리즈(Series)라는 두 가지 주요 자료구조 제공</li>
<li><strong>엑셀처럼 표 형태의 데이터 처리</strong> 가능 (행과 열로 구성)</li>
<li>데이터 <strong>정렬, 필터링, 그룹화, 결합, 통계</strong> 등 다양한 작업 지원</li>
<li>CSV, Excel, SQL, JSON 등의 <strong>다양한 파일 포맷 입출력 지원</strong></li>
</ul>
<h3 id="💡-예시-코드">💡 예시 코드</h3>
<pre><code class="language-python">import pandas as pd

# 간단한 데이터프레임 만들기
data = {&#39;이름&#39;: [&#39;철수&#39;, &#39;영희&#39;, &#39;민수&#39;],
        &#39;나이&#39;: [23, 25, 21]}

df = pd.DataFrame(data)

print(df)</code></pre>
<p>출력:</p>
<pre><code>   이름  나이
0  철수   23
1  영희   25
2  민수   21</code></pre><h3 id="🔧-pandas가-주로-쓰이는-곳">🔧 Pandas가 주로 쓰이는 곳</h3>
<ul>
<li><strong>데이터 분석</strong> (EDA)</li>
<li><strong>머신러닝 전처리</strong></li>
<li><strong>보고서 및 통계 처리</strong></li>
<li><strong>시간 시계열 분석</strong></li>
<li><strong>대용량 데이터 처리</strong></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[정처기 실기 : 2025년 1회차 기출, 1️⃣1️⃣ ~ 2️⃣0️⃣]]></title>
            <link>https://velog.io/@m_ngyeong/%EC%A0%95%EC%B2%98%EA%B8%B0-%EC%8B%A4%EA%B8%B0-2025%EB%85%84-1%ED%9A%8C%EC%B0%A8-%EA%B8%B0%EC%B6%9C-11-20</link>
            <guid>https://velog.io/@m_ngyeong/%EC%A0%95%EC%B2%98%EA%B8%B0-%EC%8B%A4%EA%B8%B0-2025%EB%85%84-1%ED%9A%8C%EC%B0%A8-%EA%B8%B0%EC%B6%9C-11-20</guid>
            <pubDate>Tue, 22 Apr 2025 06:17:18 GMT</pubDate>
            <description><![CDATA[<h1 id="정보처리기사-실기">정보처리기사 실기</h1>
<hr>
<h2 id="📝-2025년-1회차-기출-1️⃣1️⃣--2️⃣0️⃣">📝 2025년 1회차 기출, 1️⃣1️⃣ ~ 2️⃣0️⃣</h2>
<h3 id="11-c-lang---이중-포인터-malloc">11. C Lang. - 이중 포인터, malloc</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

void set(int** arr, int* data, int rows, int cols) {
    for (int i = 0; i &lt; rows * cols; ++i) {
    arr[((i + 1) / rows) % rows][(i + 1) % cols] = data[i];
    }
}

int main() {
    int rows = 3, cols = 3, sum = 0, i;
    int data[] = {5, 2, 7, 4, 1, 8, 3, 6, 9};
    int** arr;

    arr = (int**) malloc(sizeof(int*) * rows);
    for (i = 0; i &lt; rows; i++) {
        arr[i] = (int*) malloc(sizeof(int) * cols);
    }

    set(arr, data, rows, cols);

    for (i = 0; i &lt; rows * cols; i++) {
        sum += arr[i / cols][i % cols] * (i % 2 == 0 ? 1 : -1);
    }

    for(i=0; i&lt;rows; i++) {
        free(arr[i]);
    }
    free(arr);

    printf(&quot;%d&quot;, sum);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ <strong>13</strong></p>
</blockquote>
<ul>
<li><code>data</code> 배열에 있는 값을 2차원 배열 <code>arr</code>에 특정 방식으로 저장 (set 함수)</li>
<li>저장된 배열 값을 홀수 인덱스에서는 음수, 짝수 인덱스에서는 양수로 합산</li>
<li>최종적으로 <code>sum</code>을 출력<h4 id="🧩-2차원-배열을-동적으로-할당">🧩 2차원 배열을 동적으로 할당:</h4>
<pre><code class="language-c">arr = (int**) malloc(sizeof(int*) * rows);</code></pre>
</li>
<li><code>arr</code>은 <code>int</code> 포인터의 포인터, 즉 <code>int**</code>
<code>arr</code>을 <code>int*</code> 배열로 만들고 싶음</li>
<li><code>sizeof(int*) * rows</code>: <code>int*</code> 타입을 <code>rows</code>개 만큼 메모리 할당
즉, 행(<code>row</code>) 개수만큼 포인터 공간을 확보<pre><code>arr
│
├───► arr[0] → ?
├───► arr[1] → ?
└───► arr[2] → ?</code></pre><pre><code class="language-c">for (i = 0; i &lt; rows; i++) {
  arr[i] = (int*) malloc(sizeof(int) * cols);
}</code></pre>
</li>
<li><code>arr[i]</code>는 각 행에 해당하는 포인터</li>
<li><code>sizeof(int) * cols</code>: 열(<code>col</code>) 수만큼 정수 배열을 만듦
즉, 각 행에 실제 데이터를 저장할 공간을 할당<pre><code>arr
│
├───► arr[0] → [ int ][ int ][ int ] 
├───► arr[1] → [ int ][ int ][ int ] 
└───► arr[2] → [ int ][ int ][ int ] </code></pre><h4 id="🧩-set-함수">🧩 set() 함수</h4>
<pre><code class="language-c">void set(int** arr, int* data, int rows, int cols) {
  for (int i = 0; i &lt; rows * cols; ++i) {
      arr[((i + 1) / rows) % rows][(i + 1) % cols] = data[i];
  }
}</code></pre>
</li>
<li>행 인덱스: <code>((i + 1) / rows) % rows</code></li>
<li>열 인덱스: <code>(i + 1) % cols</code>
즉, <code>i</code>가 0부터 8까지 순회하면서, <code>data[i]</code> 값을 위의 인덱스 계산으로 <code>arr</code>에 넣음
<img src="https://velog.velcdn.com/images/m_ngyeong/post/70b18b32-149b-48e0-aa34-a0cb2447a69c/image.png" alt=""><h4 id="🧩-최종-arr-상태">🧩 최종 arr 상태:</h4>
<pre><code class="language-c">arr = {
{9, 5, 2},
{7, 4, 1},
{8, 3, 6}
};</code></pre>
<h4 id="🧩-sum-계산">🧩 sum 계산</h4>
<pre><code class="language-c">for (i = 0; i &lt; rows * cols; i++) {
  sum += arr[i / cols][i % cols] * (i % 2 == 0 ? 1 : -1);
}</code></pre>
2차원 배열을 순서대로 탐색하면서:</li>
<li>짝수 인덱스 <code>(i % 2 == 0)</code> → 더함</li>
<li>홀수 인덱스 → 뺌<h4 id="➡︎-9---5--2---7--4---1--8---3--6--13">➡︎ <code>9 - 5 + 2 - 7 + 4 - 1 + 8 - 3 + 6 = 13</code></h4>
</li>
</ul>
<br/>

<h3 id="12--결합도">12.  결합도</h3>
<p>① 다른 모듈 내부에 있는 변수나 기능을 다른 모듈에서 사용하는 경우의 결합도
② 모듈 간의 인터페이스로 배열이나 오브젝트, 자료구조 등이 전달되는 경우의 결합도
③  파라미터가 아닌 모듈 밖에 선언되어 있는 <strong>전역 변수</strong>를 참조하고 전역 변수를 갱신하는 식으로 상호작용하는 경우의 결합도 </p>
<blockquote>
<p>🖍️ <strong>① 내용 결합도 ② 스템프 결합도 ③ 공통 결합도</strong></p>
</blockquote>
<br/>

<h3 id="13-java-lang---oop-개념">13. Java Lang. - OOP 개념</h3>
<p><code>상속(Inheritance), 메서드 오버라이딩(Method Overriding), 정적 변수(Static Variable), 변수 숨김(Variable Shadowing)</code></p>
<pre><code class="language-java">class parent{
    static int total = 0;
    int v = 1;

    public parent(){
        total += (++v);
        show();
    }
    public void show(){
        total += total;
    }
}

class child extends parent{
    int v = 10;

    public child(){
        v += 2;
        total += v++;
        show(); 
    }
    @Override
    public void show(){
        total += total*2;
    }
}

class Main {
    public static void main(String[] args) {
        new child();
        System.out.println(parent.total);
    }
}</code></pre>
<blockquote>
<p>🖍️ <strong>54</strong></p>
</blockquote>
<h4 id="🩵-코드-시작">🩵 코드 시작:</h4>
<pre><code class="language-java">new child();</code></pre>
<h4 id="1️⃣-먼저-parent-생성자가-실행">1️⃣ 먼저 parent 생성자가 실행</h4>
<pre><code class="language-java">int v = 1;
++v;                // v는 2가 됨
total += v;         // total = 0 + 2 = 2
show();             // 여기서 child의 show()가 호출됨</code></pre>
<p>⚠️ 중요 포인트
<code>show()</code>는 <code>parent</code> 클래스의 메서드처럼 보이지만, <code>child</code> 클래스에서 오버라이딩했기 때문에, 실제로는 <code>child</code>의 <code>show()</code>가 실행됨</p>
<pre><code class="language-java">// child의 show() 실행
total += total * 2;  // 2 + (2 * 2) = 6</code></pre>
<ul>
<li><code>total</code> = 6<h4 id="2️⃣-child-생성자가-실행">2️⃣ child 생성자가 실행</h4>
<pre><code class="language-java">int v = 10;     // child의 v (부모 v와는 다른 변수)
v += 2;         // v는 12
total += v++;   // total = 6 + 12 = 18, v는 13이 됨
show();         // 다시 child의 show() 실행</code></pre>
<pre><code class="language-java">total += total * 2;  // 18 + (18 * 2) = 54</code></pre>
<h4 id="🔚-최종-결과">🔚 최종 결과</h4>
<pre><code class="language-java">System.out.println(parent.total);  // 결과: 54</code></pre>
</li>
<li>동적 바인딩으로 인해 부모 생성자에서도 자식의 메서드가 호출됨</li>
<li><code>static</code> 변수 덕분에 값이 누적되어 최종적으로 54가 출력됨</li>
</ul>
<br/>

<h3 id="14-디자인-패턴">14. 디자인 패턴</h3>
<ul>
<li>Wrapper라고도 불림</li>
<li>다른 클래스가 이용할 수 있도록 인터페이스 변환해주는 패턴</li>
</ul>
<blockquote>
<p>🖍️ <strong>adapter</strong></p>
</blockquote>
<br/>

<h3 id="15-구문-커버리지statement-coverage">15. 구문 커버리지(Statement Coverage)</h3>
<p>정확하지 않음</p>
<pre><code class="language-c">int main() {
    int a = 0;
    while (조건문) {
        if (B[a] &lt; 0)
            B[a] = -B[a];
        a++;
    }
    return(1);
}</code></pre>
<blockquote>
<p>🖍️ </p>
</blockquote>
<h4 id="순서-➊→➋→➌→➍→➎→➋→➏">순서: ➊→➋→➌→➍→➎→➋→➏</h4>
<h4 id="흐름도-구성-노드">흐름도 구성 노드</h4>
<pre><code>[Start] --&gt; [a = 0]
           |
           v
    [➊ while (조건문)]    &lt;------------------------
         /       \                                 |
       No         Yes                                 |
       |           |                                 |
 [➋ return 1]     v                                 |
               [➌ if (조건문)]                    |
                 /      \                        |
              No         Yes                    |
               |          |                        |
               |          v                        |
               |      [➍ B[a] = -B[a]]                 |
                \       /                        |
                    |                            |
                 [➎ a++]  -----------------------
                     |
              [➏ return 1] </code></pre><br/>

<h3 id="16-java-lang---재귀-함수">16. Java Lang. - 재귀 함수</h3>
<pre><code class="language-java">public class Main {
    static int comp(int[] a, int st, int end) {
        if (st &gt;= end) return 0;
        int mid = (st + end) / 2;
        return a[mid] + Math.max(comp(a, st, mid), comp(a, mid + 1, end));
    }
    public static void main(String[] args) {
        int[] values = {3, 5, 8, 12, 17};
        System.out.println(comp(values, 0, values.length - 1));
    }
}</code></pre>
<blockquote>
<p>🖍️ <strong>20</strong></p>
</blockquote>
<h4 id="🧩-main-함수">🧩 main 함수</h4>
<pre><code class="language-java">public static void main(String[] args) {
    int[] values = {3, 5, 8, 12, 17};
    System.out.println(comp(values, 0, values.length - 1));
}</code></pre>
<ul>
<li><code>comp</code> 함수는 <code>values</code> 배열을 <code>0</code>부터 <code>values.length - 1</code> (즉, 0부터 4까지)까지의 범위로 분할하여 실행</li>
<li><code>comp</code> 함수는 재귀적으로 배열을 나누고, 각 부분에서 가장 큰 값을 구해 반환<h4 id="🧩-comp-함수">🧩 comp 함수</h4>
<pre><code class="language-java">static int comp(int[] a, int st, int end) {
  if (st &gt;= end) return 0;
  int mid = (st + end) / 2;
  return a[mid] + Math.max(comp(a, st, mid), comp(a, mid + 1, end));
}</code></pre>
<code>comp</code> 함수는 배열 <code>a</code>와 인덱스 <code>st(start)</code>와 <code>end(end)</code>를 인자로 받아서 <strong>부분 배열의 합</strong>을 구하고, 그 중에서 <strong>최대값을 반환</strong>하는 함수</li>
<li>재귀 종료 조건: <code>st &gt;= end</code>이면 0을 반환, 이 조건은 배열의 크기가 1 이하일 때 재귀가 종료</li>
<li>분할: 배열을 두 부분으로 나눔, <code>mid</code>는 배열의 중간 인덱스</li>
<li>부분합 계산: <code>comp(a, st, mid)</code>는 <code>st</code>부터 <code>mid</code>까지의 부분 배열을 처리하고, <code>comp(a, mid + 1, end)</code>는 <code>mid + 1</code>부터 <code>end</code>까지의 부분 배열을 처리</li>
<li>최대값 구하기: 두 부분의 결과를 비교한 후 더 큰 값을 선택하고, <code>a[mid]</code> 값을 더해 최종 결과를 계산<h4 id="✅-compvalues-0-4-실행-흐름-표">✅ comp(values, 0, 4) 실행 흐름 표</h4>
<img src="https://velog.velcdn.com/images/m_ngyeong/post/6bc0e92f-db41-4e54-a34e-5afb38990300/image.png" alt=""><pre><code class="language-scss">comp(0,4) → 8+12
├── comp(0,2) → a[1]+3+0 = 8
│   ├── comp(0,1) → a[0]+0+0 = 3
│   │   ├── comp(0,0) → 0
│   │   └── comp(1,1) → 0
│   └── comp(2,2) → 0
├── comp(3,4) → a[3]+0+0 = 12
│   ├── comp(3,3) → 0
│   └── comp(4,4) → 0</code></pre>
</li>
</ul>
<br/>

<h3 id="17-python-lang---이진-트리">17. Python Lang. - 이진 트리</h3>
<pre><code class="language-python">class TreeNode:
    def __init__(self, value):
        self.value = value
        self.children = []

def build_tree(li):
    nodes = [TreeNode(i) for i in li]
    for i in range(1, len(li)):
        nodes[(i - 1) // 2].children.append(nodes[i])
    return nodes[0]

def calc(node, level=0):
    return node.value if level % 2 else 0 + sum(calc(n, level + 1) for n in node.children) if node else 0

li = [3, 5, 8, 12, 15, 18, 20]
root = build_tree(li)
print(calc(root))</code></pre>
<blockquote>
<p>🖍️ <strong>13</strong></p>
</blockquote>
<h4 id="🩵-클래스-treenode-정의">🩵 클래스 TreeNode 정의</h4>
<pre><code class="language-python">class TreeNode:
    def __init__(self, value):
        self.value = value
        self.children = []</code></pre>
<ul>
<li><code>TreeNode</code> 클래스는 트리의 각 노드를 나타냄</li>
<li><code>__init__()</code>: 노드의 값을 설정, 자식 노드들을 담을 <code>children</code> 리스트를 초기화<h4 id="🩵-build_tree-함수">🩵 build_tree 함수</h4>
<pre><code class="language-python">def build_tree(li):
  nodes = [TreeNode(i) for i in li]
  for i in range(1, len(li)):
      nodes[(i - 1) // 2].children.append(nodes[i])
  return nodes[0]</code></pre>
</li>
<li><code>build_tree</code> 함수는 입력 리스트 <code>li</code>를 이용해 트리를 만듦
먼저, <code>li</code>의 각 값에 대해 <code>TreeNode</code> 인스턴스를 만들어 <code>nodes</code> 리스트에 저장</li>
<li>이후 <code>for</code> 루프를 통해 각 노드의 부모 노드를 찾아서 자식으로 추가<ul>
<li><code>nodes[(i - 1) // 2]</code>는 현재 노드 <code>i</code>의 부모 노드를 가리킴</li>
<li>예를 들어, <code>i = 1</code>일 때, <code>(i - 1) // 2 = 0</code>으로, 노드 1의 부모는 노드 0</li>
</ul>
</li>
<li>마지막으로 트리의 루트 노드(<code>nodes[0]</code>)를 반환
<img src="https://velog.velcdn.com/images/m_ngyeong/post/2a9afcf9-9604-4299-808b-5e5f2abc10de/image.png" alt=""><h4 id="🌳-결과-트리-구조">🌳 결과 트리 구조</h4>
<pre><code>nodes[0]: 3
├── nodes[1]: 5
│   ├── nodes[3]: 12
│   └── nodes[4]: 15
└── nodes[2]: 8
  ├── nodes[5]: 18
  └── nodes[6]: 20</code></pre><h4 id="🩵-calc-함수">🩵 calc 함수</h4>
<code>calc</code> 함수는 트리의 각 노드를 <strong>깊이 우선 탐색(DFS)</strong> 방식으로 순회하며 계산한다.<pre><code class="language-python">def calc(node, level=0):
  return node.value if level % 2 else 0 + sum(calc(n, level + 1) for n in node.children) if node else 0</code></pre>
</li>
<li><code>level=0</code>: 루트(시작점)</li>
<li><code>level</code>: 현재 노드가 트리의 몇 번째 레벨인지를 나타냄<h4 id="🔍-핵심-조건부-삼항-연산자">🔍 핵심: 조건부 삼항 연산자</h4>
<pre><code class="language-python">return (
  node.value if level % 2           # 👉 레벨이 홀수면 자기 값 반환
  else 0 + sum(...)                 # 👉 짝수면 자기 값 무시하고 자식 노드들의 결과만 합침
  if node                           # 👉 node가 None이면 무조건 0 반환
  else 0
)</code></pre>
</li>
<li><strong>True = 1 / False = 0</strong></li>
<li><code>node.value</code>: 현재 노드 값</li>
<li>기본적으로, 노드의 값은 깊이에 따라 다르게 처리됨<ul>
<li><code>level % 2 == 1</code>: <strong>홀수, <code>node.value</code> + 자식들 합</strong></li>
<li><code>level % 2 == 0</code>: <strong>짝수, 자신의 값은 무시 + 자식들 합</strong></li>
</ul>
</li>
<li><code>sum(calc(n, level + 1) for n in node.children)</code>
현재 노드의 모든 자식 노드들에 대해 <code>calc()</code>를 호출해서 합산, 재귀 호출</li>
<li><code>node == None</code>일 경우, 0을 반환<pre><code class="language-scss">nodes[0]: 3 → 무시
├── nodes[1]: 5 → 포함
│   ├── nodes[3]: 12 → 무시
│   └── nodes[4]: 15 → 무시
└── nodes[2]: 8 → 포함
  ├── nodes[5]: 18 → 무시
  └── nodes[6]: 20 → 무시</code></pre>
<img src="https://velog.velcdn.com/images/m_ngyeong/post/447c38e8-0992-496b-82a5-3ede516ab602/image.png" alt=""><h4 id="🩵-실행">🩵 실행</h4>
<pre><code class="language-python">li = [3, 5, 8, 12, 15, 18, 20]
root = build_tree(li)
print(calc(root))</code></pre>
<pre><code>      3
     / \
    5   8
   / \  / \
  12 15 18 20</code></pre></li>
<li>5 + 8 = 13</li>
</ul>
<br/>

<h3 id="18-c-lang---연결리스트">18. C Lang. - 연결리스트</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

typedef struct Node {
    int value;
    struct Node *next;
} Node;

Node* createNode(Node* head, int value) {
    Node* new_node = (Node*)malloc(sizeof(Node));
    new_node-&gt;value = value;
    new_node-&gt;next = head;
    return new_node;
}

Node* reconnect(Node* head, int disconnect_count) {
    Node *prev = NULL, *curr = head;

    while (curr &amp;&amp; curr-&gt;value != disconnect_count) {
        prev = curr;
        curr = curr-&gt;next;
    }

    if (!curr || curr == head) return head;

    prev-&gt;next = curr-&gt;next;
    curr-&gt;next = head;
    head = curr;

    return head;
}

int main() {
    Node *head = NULL, *curr, *temp;
    for (int i = 1; i &lt;= 5; i++)
        head = createNode(head, i);

    head = reconnect(head, 3);

    for (curr = head; curr != NULL; curr = curr-&gt;next)
        printf(&quot;%d&quot;, curr-&gt;value);

    // 메모리 해제
    curr = head;
    while (curr != NULL) {
        temp = curr;
        curr = curr-&gt;next;
        free(temp);
    }

    return 0;
}</code></pre>
<blockquote>
<p>🖍️ <strong>35421</strong></p>
</blockquote>
<h4 id="🧩-구조체-정의">🧩 구조체 정의</h4>
<pre><code class="language-c">typedef struct Node {
    int value;
    struct Node *next;
} Node;</code></pre>
<ul>
<li><code>Node</code>라는 이름의 구조체를 정의</li>
<li><code>value</code>: 노드가 가지고 있는 값 (int형).</li>
<li><code>next</code>: 다음 노드를 가리키는 포인터, 이 포인터를 통해 연결된 리스트를 구성<h4 id="🧩-새-노드-생성-함수">🧩 새 노드 생성 함수</h4>
<pre><code class="language-c">Node* createNode(Node* head, int value) {
  Node* new_node = (Node*)malloc(sizeof(Node));
  new_node-&gt;value = value;
  new_node-&gt;next = head;
  return new_node;
}</code></pre>
<code>createNode()</code> 함수는 새로운 노드를 생성하여 리스트의 맨 앞에 추가하는 함수</li>
<li><code>malloc</code>을 사용하여 새로운 Node를 동적으로 할당</li>
<li>할당된 새로운 노드의 <code>value</code>를 주어진 <code>value</code>로 설정</li>
<li>새로운 노드의 <code>next</code>는 현재의 <code>head</code>를 가리키도록 설정하여, 리스트의 맨 앞에 이 노드를 추가</li>
<li>함수는 생성된 <code>new_node</code>를 반환<h4 id="🧩-연결-리스트에서-특정-노드를-맨-앞으로-이동시키는-함수">🧩 연결 리스트에서 특정 노드를 맨 앞으로 이동시키는 함수</h4>
<pre><code class="language-c">Node* reconnect(Node* head, int disconnect_count) {
  Node *prev = NULL, *curr = head;
  ...
}</code></pre>
<code>reconnect</code> 함수는 특정 값(<code>disconnect_count</code>)을 가진 노드를 리스트에서 찾아 맨 앞으로 이동시키는 함수</li>
<li><code>prev</code>: 현재 노드의 이전 노드를 가리키는 포인터</li>
<li><code>curr</code>: 현재 노드를 가리키는 포인터, 초기에는 <code>head</code>로 설정됨<pre><code class="language-c">while (curr &amp;&amp; curr-&gt;value != disconnect_count) {
    prev = curr;
    curr = curr-&gt;next;
}</code></pre>
<code>while</code> 루프를 통해 리스트를 탐색하여 <code>disconnect_count</code> 값과 일치하는 노드를 찾음</li>
<li><code>prev</code>는 항상 <code>curr</code>의 이전 노드를 추적</li>
<li><code>curr</code>는 현재 노드를 추적<pre><code class="language-c">if (!curr || curr == head) return head;</code></pre>
</li>
<li><code>curr</code>이 <code>NULL</code>이면 값을 찾지 못한 경우이고, <code>curr == head</code>이면 이미 맨 앞에 있는 경우 </li>
<li>그런 경우에는 아무것도 하지 않고 <code>head</code>를 그대로 반환<pre><code class="language-c">prev-&gt;next = curr-&gt;next;
curr-&gt;next = head;
head = curr;</code></pre>
</li>
<li><code>prev-&gt;next = curr-&gt;next</code>: <code>prev</code> 노드의 <code>next</code>가 <code>curr</code>의 <code>next</code>를 가리키도록 하여 <code>curr</code> 노드를 리스트에서 분리</li>
<li><code>curr-&gt;next = head</code>: <code>curr</code> 노드를 리스트의 맨 앞에 추가하기 위해 <code>curr-&gt;next</code>를 기존 <code>head</code>로 설정</li>
<li><code>head = curr</code>: <code>head</code>를 <code>curr</code>로 변경하여 리스트의 첫 번째 노드를 <code>curr</code>로 설정<pre><code>head
↓
[5] → [4] → [3] → [2] → [1] → NULL
↑      ↑
prev   curr
head
↓
[5] → [4] → [3] → [2] → [1] → NULL
             ↑      ↑
           prev    curr
• prev-&gt;next = curr-&gt;next → 4 → 2
• curr-&gt;next = head → 3 → 5
• head = curr → 새로운 head는 3</code></pre><h4 id="🧩-main-함수-1">🧩 main 함수</h4>
<pre><code class="language-c">int main() {
  Node *head = NULL, *curr, *temp;
  for (int i = 1; i &lt;= 5; i++)
      head = createNode(head, i);
  ...
}</code></pre>
</li>
<li><code>Node *head = NULL</code>: 리스트의 헤드를 NULL로 초기화(빈 리스트)</li>
<li><code>for (int i = 1; i &lt;= 5; i++)</code>: 1부터 5까지 숫자를 가진 노드들을 생성하여 연결 리스트를 만듦</li>
<li><code>createNode</code> 함수를 사용하여 각 숫자에 대한 노드를 리스트의 맨 앞에 추가
결과적으로 <code>head</code>는 <code>5 -&gt; 4 -&gt; 3 -&gt; 2 -&gt; 1</code>로 초기화됨<pre><code class="language-c">head = reconnect(head, 3);</code></pre>
</li>
<li>3을 리스트에서 찾아서 맨 앞에 이동시킴</li>
<li>결과적으로 리스트는 <code>3 -&gt; 5 -&gt; 4 -&gt; 2 -&gt; 1</code><pre><code class="language-c">for (curr = head; curr != NULL; curr = curr-&gt;next)
 printf(&quot;%d&quot;, curr-&gt;value);</code></pre>
</li>
<li>리스트의 모든 값을 출력하는 루프</li>
<li><code>head</code>부터 시작하여 각 노드를 출력
<img src="https://velog.velcdn.com/images/m_ngyeong/post/5b8f7a3a-8801-44d2-bd96-8fe787785ebd/image.png" alt=""><h4 id="🧩-메모리-해제">🧩 메모리 해제</h4>
<pre><code class="language-c">curr = head;
while (curr != NULL) {
  temp = curr;
  curr = curr-&gt;next;
  free(temp);
}</code></pre>
동적으로 할당한 메모리를 해제하는 코드</li>
<li><code>curr</code>는 리스트의 현재 노드를 가리키고, <code>temp</code>는 메모리 해제를 위한 임시 포인터</li>
<li><code>curr</code>를 리스트를 따라 이동시키면서, 각 노드의 메모리를 <code>free</code> 함수로 해제</li>
<li><code>free(temp)</code>로 <code>curr</code>가 가리키는 노드를 해제한 후, <code>curr</code>을 다음 노드로 이동시킴</li>
</ul>
<br/>

<h3 id="19-c-lang---16진수">19. C Lang. - 16진수</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

typedef struct student {
    char* name;
    unsigned int score[3];
} Student;

int dec(int enc) {
    return enc &amp; 0xA5;
}

int sum(Student* p) {
    return dec(p-&gt;score[0]) + dec(p-&gt;score[1]) + dec(p-&gt;score[2]);
}

int main() {
    Student s[2] = { &quot;Kim&quot;, {0xF0, 0xF5, 0xDB}, &quot;Lee&quot;, {0xED, 0xD3, 0xF2} };
    Student* p = s;
    int result = 0;

    for (int i = 0; i &lt; 2; i++) {
        result += sum(&amp;s[i]);
    }
    printf(&quot;%d&quot;, result);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ <strong>908</strong></p>
</blockquote>
<h4 id="🧩-구조체-정의-1">🧩 구조체 정의</h4>
<pre><code class="language-c">typedef struct student {
    char* name;
    int score[3];
} Student;</code></pre>
<ul>
<li><code>Student</code> 구조체는 학생의 이름과 점수 3개를 저장</li>
<li><code>score[3]</code> 배열은 3개의 정수 점수를 저장
다만, 이 점수는 인코딩된 형태<h4 id="🧩-디코딩-함수">🧩 디코딩 함수</h4>
<pre><code class="language-c">int dec(int enc) {
  return enc &amp; 0xA5;
}</code></pre>
</li>
<li><code>&amp;</code> 연산자는 비트 <code>AND</code> 연산</li>
<li><code>0xA5</code>는 16진수로 10100101</li>
<li>즉, 인코딩된 점수에서 특정 비트만 남겨서 &quot;디코딩&quot;하는 역할<pre><code>Kim:
0xF0(11110000)` &amp; 0xA5(10100101) = 0xA0(10100000) = 160
0xF5(11110101) &amp; 0xA5 = 0xA5 = 165
0xDB &amp; 0xA5 = 0x81 = 129 
→ Kim의 총합: 160 + 165 + 129 = 454
Lee:
0xED &amp; 0xA5 = 0xA5 = 165 
0xD3 &amp; 0xA5 = 0x81 = 129 
0xF2 &amp; 0xA5 = 0xA0 = 160
→ Lee의 총합: 165 + 129 + 160 = 454</code></pre><h4 id="🧩-합산-함수">🧩 합산 함수</h4>
<pre><code class="language-c">int sum(Student* p) {
  return dec(p-&gt;score[0]) + dec(p-&gt;score[1]) + dec(p-&gt;score[2]);
}</code></pre>
</li>
<li>특정 학생 포인터 <code>p</code>의 세 점수를 디코딩해서 더함<h4 id="🧩-main-함수-2">🧩 main 함수</h4>
<pre><code class="language-c">for (int i = 0; i &lt; 2; i++) {
      result += sum(&amp;s[i]);
  }
  printf(&quot;%d&quot;, result);</code></pre>
</li>
<li><code>result</code> = <code>sum[0] + sum[1]</code> = 454 + 454 = 908</li>
</ul>
<br/>

<h3 id="20-java-lang---재귀-함수-overloading">20. Java Lang. - 재귀 함수, Overloading</h3>
<pre><code class="language-java">public class Main {
    public static void main(String[] args) {
    System.out.println(calc(&quot;5&quot;));
    }

    static int calc(int value) {
        if (value &lt;= 1) return value;
        return calc(value - 1) + calc(value - 2);
    }

    static int calc(String str) {
        int value = Integer.valueOf(str);
        if (value &lt;= 1) return value;
        return calc(value - 1) + calc(value - 3);
    }
}</code></pre>
<blockquote>
<p>🖍️ <strong>4</strong></p>
</blockquote>
<h4 id="🩵-main">🩵 main()</h4>
<pre><code class="language-java">public class Mian {
    public static void main(String[] args) {
        System.out.println(calc(&quot;5&quot;));
    }</code></pre>
<ul>
<li><code>main()</code> 함수에서 &quot;5&quot;라는 문자열을 <code>calc()</code> 함수에 넘김</li>
<li>문자열이므로 호출되는 건 <code>calc(String str)</code><h4 id="🩵-메서드-오버로딩-overloading">🩵 메서드 오버로딩 (Overloading)</h4>
<pre><code class="language-java">static int calc(String str) {
  int value = Integer.valueOf(str);
  if (value &lt;= 1) return value;
  return calc(value - 1) + calc(value - 3);
}</code></pre>
</li>
<li><code>Integer.valueOf(str);</code> : 문자열을 정수로 변환</li>
<li>재귀적으로 <code>calc(int)</code>를 호출! (value - 1, value - 3)</li>
<li>⚠️ 주의: 여기서 호출되는 <code>calc(value - 1) + calc(value - 3)</code>은 <code>int</code> 버전의 <code>calc()</code><h4 id="🔍-동작-순서-분석">🔍 동작 순서 분석</h4>
<pre><code class="language-java">&quot;5&quot; → calc(String) 호출됨
value = 5
calc(5 - 1) + calc(5 - 3) = calc(4) + calc(2)</code></pre>
<h4 id="📌-calc4---static-int-calcint-value">📌 calc(4) - static int calc(int value)</h4>
<pre><code class="language-java">calc(4 - 1) + calc(4 - 2)
= calc(3) + calc(2)
= (calc(2) + calc(1)) + (calc(1) + calc(0))
= ((calc(1) + calc(0)) + 1) + (1 + 0)
= ((1 + 0) + 1) + (1 + 0)
= (1 + 1) + 1 
= 2 + 1 = 3</code></pre>
<h4 id="📌-calc2---static-int-calcint-value">📌 calc(2) - static int calc(int value)</h4>
<pre><code class="language-java">calc(2 - 1) + calc(2 - 2)
calc(1) + calc(0) 
= 1 + 0 = 1</code></pre>
<h4 id="🩵-최종-결과">🩵 최종 결과</h4>
<pre><code>calc(&quot;5&quot;) = calc(4) + calc(2) = 3 + 1 = 4</code></pre></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[정처기 실기 : 2025년 1회차 기출, 1️⃣ ~ 🔟
]]></title>
            <link>https://velog.io/@m_ngyeong/%EC%A0%95%EC%B2%98%EA%B8%B0-%EC%8B%A4%EA%B8%B0-2025%EB%85%84-1%ED%9A%8C%EC%B0%A8-%EA%B8%B0%EC%B6%9C-1</link>
            <guid>https://velog.io/@m_ngyeong/%EC%A0%95%EC%B2%98%EA%B8%B0-%EC%8B%A4%EA%B8%B0-2025%EB%85%84-1%ED%9A%8C%EC%B0%A8-%EA%B8%B0%EC%B6%9C-1</guid>
            <pubDate>Mon, 21 Apr 2025 02:43:44 GMT</pubDate>
            <description><![CDATA[<h1 id="정보처리기사-실기">정보처리기사 실기</h1>
<hr>
<h2 id="📝-2025년-1회차-기출-1️⃣--🔟">📝 2025년 1회차 기출, 1️⃣ ~ 🔟</h2>
<h3 id="1-소프트웨어-보안">1. 소프트웨어 보안</h3>
<ul>
<li>케빈 미트닉이 사용했던 공격 방법이다.</li>
<li>( )은/는 &#39;세션을 가로채다&#39;라는 의미로, 사용자가 인증을 마친 후 유지되고 있는 세션 ID를 탈취하거나 위조하여 마치 정상 사용자처럼 접근하는 방식이다.</li>
<li>TCP ( )은/는 TCP 연결의 시퀀스 번호를 예측하거나 가로채어 통신 흐름에 불법적으로 끼어드는 방식으로 이루어진다. 이를 통해 공격자는 피해자의 세션을 탈취하거나 조작할 수 있다.</li>
<li>( )은/는 세션 관리 취약점을 이용한 공격 기법이다.</li>
</ul>
<blockquote>
<p>🖍️ <strong>세션 하이재킹</strong></p>
</blockquote>
<br/>

<h3 id="2-db-무결성-제약-조건">2. DB 무결성 제약 조건</h3>
<table>
<thead>
<tr>
<th align="center"></th>
<th align="center">①</th>
<th align="center">②</th>
<th align="center">③</th>
</tr>
</thead>
<tbody><tr>
<td align="center">대상</td>
<td align="center">속성</td>
<td align="center">튜플</td>
<td align="center">속성, 튜플</td>
</tr>
<tr>
<td align="center">NULL 허용</td>
<td align="center">X</td>
<td align="center">O</td>
<td align="center">X</td>
</tr>
<tr>
<td align="center">기준</td>
<td align="center">데이터 타입, 값 범위</td>
<td align="center">기본 키 조건</td>
<td align="center">외래 키 → 부모 테이블의 키</td>
</tr>
<tr>
<td align="center">설명</td>
<td align="center">속성에 입력될 수 있는 값의 형식, 범위, 길이 등을 제한하여 올바른 값 유지</td>
<td align="center">각 튜플을 고유하게 식별할 수 있도록 기본 키는 NULL / 중복이 될 수 없음</td>
<td align="center">외래키가 참조하는 기본키는 반드시 원본 테이블에 존재해야 하며, 테이블 간의 연관성, 일관성을 보장함</td>
</tr>
</tbody></table>
<blockquote>
<p>🖍️ <strong>① 도메인 무결성 ② 개체 무결성 ③ 참조 무결성</strong></p>
</blockquote>
<br/>

<h3 id="3-오류-감지-기법">3. 오류 감지 기법</h3>
<p>( )은/는 영어 3글자 약자로 이루어진 <strong>오류 감지 기법</strong>으로,
연속된 비트 오류를 감지하는데 효과적이며, 주로 데이터를 전송이나 저장 시 무결성을 확인하는데 사용된다. 다항식 기반의 계산을 통해 전송된 데이터에 오류가 있는지를 수신 측에서 판별할 수 있다.</p>
<blockquote>
<p>🖍️ <strong>CRC</strong></p>
</blockquote>
<br/>

<h3 id="4-소프트웨어-보안">4. 소프트웨어 보안</h3>
<p>( )은/는 <strong>사회공학적 기법</strong>을 활용한 악성 소프트웨어의 한 유형이다. 사용자를 위헙하거나 공포심을 유발하여 특정 행동을 하도록 유도하는 악성 소프트웨어이다. 주로 <strong>가짜 바이러스 경고</strong>나 시스템 문제를 표시하여 사용자가 돈을 지불하거나 특정 소프트웨어를 설치하도록 속이는 방식으로 작동한다.
<code>[보기] 셔블웨어, 애드웨어, 스캐어웨어, 안티 스파이웨어, ...</code></p>
<blockquote>
<p>🖍️ <strong>스캐어웨어</strong></p>
</blockquote>
<br/>

<h3 id="5-java-lang---try-catchfinally">5. Java Lang. - try-catch~finally</h3>
<pre><code class="language-java">public class Main {
    public static void main(String[] args) {
        try{
            int a=5,b=0;
            System.out.print(a/b);
        }
        catch(ArithmeticException e){
            System.out.print(&quot;출력1&quot;);
        }
        catch(ArrayIndexOutOfBoundsException e) {
            System.out.print(&quot;출력2&quot;);
        }
        catch(NumberFormatException e) {
            System.out.print(&quot;출력3&quot;);
        }
        catch(Exception e){
            System.out.print(&quot;출력4&quot;);
        }
        finally{
            System.out.print(&quot;출력5&quot;);
        }
    }
}</code></pre>
<blockquote>
<p>🖍️ <strong>출력1출력5</strong></p>
</blockquote>
<pre><code class="language-java">int a=5,b=0;
            System.out.print(a/b);</code></pre>
<p><code>a / b</code> → 5 / 0을 계산하려는 순간
➤  런타임 에러 <code>ArithmeticException</code> 발생!
➤ <code>System.out.print()</code>는 호출조차 안 됨!
➤ <code>try</code> 블록이 중단되고 바로 해당 <code>catch</code>로 이동함</p>
<h4 id="🔹-catch-블록">🔹 catch 블록</h4>
<pre><code class="language-java">catch (ArithmeticException e) {
    System.out.print(&quot;출력1&quot;);
}</code></pre>
<ul>
<li>예외 타입이 정확히 맞음 → 이 블록 실행됨</li>
<li>출력: 출력1<h4 id="다른-catch들은-무시되고">다른 <code>catch</code>들은 무시되고,</h4>
<h4 id="🔹-finally-블록">🔹 finally 블록</h4>
<pre><code class="language-java">finally {
  System.out.print(&quot;출력5&quot;);
}</code></pre>
</li>
<li><code>finally</code>는 예외가 발생하든 말든 <strong>무조건 실행됨</strong></li>
<li>출력: 출력5</li>
</ul>
<p>➕ </p>
<ul>
<li><code>ArithmeticException</code>: 0으로 나누기 같은 <strong>산술 계산</strong><pre><code class="language-java">int x = 10 / 0;  // ArithmeticException 발생</code></pre>
</li>
<li><code>ArrayIndexOutOfBoundsException</code>: <strong>배열 범위 초과 인덱스 접근</strong><pre><code class="language-java">int[] arr = {1, 2, 3};
int x = arr[5];  // 인덱스 5는 없음 → 예외 발생</code></pre>
</li>
<li><code>NumberFormatException</code>: <code>&quot;abc&quot;</code> 같은 문자열 → 숫자 변환 시<pre><code class="language-java">String s = &quot;hello&quot;;
int x = Integer.parseInt(s);  // &quot;hello&quot;는 숫자가 아님 → 예외 발생</code></pre>
</li>
<li><code>Exception</code>: <strong>모든 예외의 최상위 클래스</strong>(일반 예외 포괄)<ul>
<li>위의 세 가지 예외들도 <code>Exception</code>을 상속받음 </li>
<li>특정 예외를 명시하지 않고, <strong>모든 예외를 통틀어 잡고 싶을 때</strong> 사용<pre><code class="language-java">try {
// 어떤 예외가 날지 모를 때
} catch(Exception e) {
// 모든 예외를 처리
}</code></pre>
</li>
</ul>
</li>
</ul>
<br/>

<h3 id="6-프로토콜">6. 프로토콜</h3>
<p>① IP 네트워크상에서 IP 주소를 물리 주소(MAC 주소)로 변환하는 프로토콜
② 물리적 주소(MAC 주소)를 IP 주소로 변환하는 프로토콜</p>
<blockquote>
<p>🖍️ <strong>① ARP ② RARP</strong></p>
</blockquote>
<br/>

<h3 id="7-sql">7. SQL</h3>
<p>[emp]</p>
<table>
<thead>
<tr>
<th align="center">id</th>
<th align="center">name</th>
<th align="center"></th>
</tr>
</thead>
<tbody><tr>
<td align="center">1001</td>
<td align="center">강감찬</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">1002</td>
<td align="center">김유신</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">1003</td>
<td align="center">이순신</td>
<td align="center"></td>
</tr>
</tbody></table>
<p>[sal]</p>
<table>
<thead>
<tr>
<th align="center">id</th>
<th align="left">incentive</th>
</tr>
</thead>
<tbody><tr>
<td align="center">1001</td>
<td align="left">300</td>
</tr>
<tr>
<td align="center">1002</td>
<td align="left">200</td>
</tr>
<tr>
<td align="center">1003</td>
<td align="left">1000</td>
</tr>
<tr>
<td align="center">1009</td>
<td align="left">500</td>
</tr>
</tbody></table>
<pre><code class="language-sql">[SQL]
SELECT name, incentive FROM emp, sal WHERE emp.id = sal.id and incentive &gt;= 500;</code></pre>
<blockquote>
<p>🖍️ <img src="https://velog.velcdn.com/images/m_ngyeong/post/62a5aba6-8bf1-4d7e-9b8d-6f82063fe697/image.png" alt=""></p>
</blockquote>
<pre><code class="language-sql">// CREATE
CREATE TABLE emp
(   id       NUMBER NOT NULL,
    name     VARCHAR(10) NOT NULL);
CREATE TABLE sal
(   id        NUMBER NOT NULL,
    incentive NUMBER NOT NULL);
// INSERT
INSERT INTO emp (id, name)
VALUES 
    (1, &#39;강감찬&#39;),
    (2, &#39;김유신&#39;),
    (3, &#39;이순신&#39;);
INSERT INTO sal (id, incentive)
VALUES 
    (1, 300),
    (2, 200),
    (3, 1000),
    (4, 500);</code></pre>
<br/>

<h3 id="8-관계형-데이터베이스의-용어">8. 관계형 데이터베이스의 용어</h3>
<p>① 릴레이션에서 <strong>속성(차수)의 개수</strong>를 의미: ( )
② 릴레이션에서 <strong>튜플의 개수</strong>를 의미: ( )
③ 한 릴레이션(테이블)의 속성이 다른 테이블의 기본 키를 참조할 때, <strong>참조하는 키</strong>: ( ) key
④ 특정 속성에 대해 입력될 수 있는 <strong>값의 유형이나 범위</strong>를 의미하며, 무결성을 보장하기 위한 기준: ( )</p>
<pre><code>[보기]
ㄱ domain ㄴ primary ㄷ degree ㄹ candidate
ㅁ cardinality ㅂ attribute ㅅ foreign</code></pre><blockquote>
<p>🖍️ <strong>① ㄷ degree, ② ㅁ cardinality, ③ ㅅ foreign, ④ ㄱ domain</strong></p>
</blockquote>
<br/>

<h3 id="9-서브넷-마스크">9. 서브넷 마스크</h3>
<p><strong>IP: 192.168.35.10
서브넷 마스크: 255.255.252.0</strong></p>
<pre><code>[보기]
ㄱ 192.168.32.xxx ㄴ 192.168.34.xxx ㄷ 192.168.35.xxx ㄹ 192.168.32.xxx ㅁ 192.168.35.xxx</code></pre><blockquote>
<p>🖍️ <strong>ㄱ,ㄴ,ㄷ,ㄹ,ㅁ</strong>
252 = 11111100
35 = 00100011</p>
</blockquote>
<ul>
<li>네트워크 주소 = 192.168.32.000 </li>
<li>브로드캐스트 주소 = 192.168.35.255</li>
<li>∴ 사용 가능한 IP 주소 범위: <strong>192.168.32.1 ~ 192.168.35.254</strong></li>
</ul>
<br/>

<h3 id="10-c-lang---ascii-코드">10. C Lang. - ASCII 코드</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
char Data[5] = {&#39;B&#39;, &#39;A&#39;, &#39;D&#39;, &#39;E&#39;};
char c;

int main(){
    int i, temp, temp2;
    c = &#39;C&#39;;
    printf(&quot;%d\n&quot;, Data[3]-Data[1]);

    for(i=0;i&lt;5;++i){
        if(Data[i]&gt;c)
            break;
    }

    temp = Data[i];
    Data[i] = c;
    i++;

    for(;i&lt;5;++i){
        temp2 = Data[i];
        Data[i] = temp;
        temp = temp2;
    }

    for(i=0;i&lt;5;i++){
        printf(&quot;%c&quot;, Data[i]);
    }

    return 0;
}</code></pre>
<blockquote>
<p>🖍️ **
4
BACDE**</p>
</blockquote>
<h4 id="💚-1-출력-data3-data1">💚 1. 출력: Data[3]-Data[1]</h4>
<pre><code class="language-c">printf(&quot;%d\n&quot;, Data[3]-Data[1]);</code></pre>
<ul>
<li><code>Data[3]</code> = &#39;E&#39;,<code>Data[1]</code> = &#39;A&#39;</li>
<li>&#39;E&#39; - &#39;A&#39; = 69 - 65 = 4</li>
<li>출력: 4<h4 id="💚-2-삽입-위치-찾기">💚 2. 삽입 위치 찾기</h4>
<pre><code class="language-c">for(i=0; i&lt;5; ++i){
  if(Data[i] &gt; c)
      break;
}</code></pre>
</li>
<li>문자 &#39;C&#39;보다 큰 값을 찾을 때까지 반복</li>
<li>비교 순서:
<code>Data[0]</code> = &#39;B&#39; → &#39;B&#39; &lt; &#39;C&#39; → 계속
<code>Data[1]</code> = &#39;A&#39; → &#39;A&#39; &lt; &#39;C&#39; → 계속
<code>Data[2]</code> = &#39;D&#39; → &#39;D&#39; &gt; &#39;C&#39; → break!
→ <code>i == 2</code> 에서 멈춤 ⇒ &#39;C&#39;는 인덱스 2에 삽입될 예정<h4 id="💚-3-배열에-c-삽입">💚 3. 배열에 &#39;C&#39; 삽입</h4>
<pre><code class="language-c">temp = Data[i];
Data[i] = c;
i++;
for(; i&lt;5; ++i){
  temp2 = Data[i];
  Data[i] = temp;
  temp = temp2;
}</code></pre>
</li>
<li><code>i = 2</code></li>
<li><code>Data[2]</code> = &#39;D&#39;를 temp에 저장하고 &#39;C&#39;로 대체</li>
<li>이후 한 칸씩 뒤로 밀면서 값 shift<h4 id="💚-4-최종-출력">💚 4. 최종 출력</h4>
<pre><code class="language-c">for(i=0; i&lt;5; i++){
  printf(&quot;%c&quot;, Data[i]);
}</code></pre>
→ 출력 결과: BACDE</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[SQL: JSON_EXTRACT()]]></title>
            <link>https://velog.io/@m_ngyeong/SQL-JSONEXTRACT</link>
            <guid>https://velog.io/@m_ngyeong/SQL-JSONEXTRACT</guid>
            <pubDate>Wed, 16 Apr 2025 04:08:01 GMT</pubDate>
            <description><![CDATA[<h1 id="💾-sql">💾 SQL</h1>
<hr>
<h2 id="json_extractjson_column-key">JSON_EXTRACT(json_column, &#39;$.key&#39;)</h2>
<p><strong>JSON 형태로 저장된 데이터</strong>에서 할 때 사용하는 함수이다.</p>
<ul>
<li>예를 들어 아래처럼 생긴 JSON이 있다고 해보자:<pre><code class="language-json">{
&quot;price&quot;: 100,
&quot;qty&quot;: 3
}</code></pre>
</li>
<li>이 JSON이 json_data라는 컬럼에 저장돼 있다면:<pre><code class="language-sql">SELECT JSON_EXTRACT(json_data, &#39;$.price&#39;) 
FROM your_table;
// 100</code></pre>
</li>
</ul>
<h3 id="💡-sumjson_extract">💡 SUM(JSON_EXTRACT(...))?</h3>
<p>추출한 값들을 전부 더하는 함수이다.</p>
<pre><code class="language-sql">SELECT SUM(JSON_EXTRACT(json_data, &#39;$.price&#39;)) AS total_price
FROM your_table;</code></pre>
<p>→ 각 행의 JSON에서 <code>price</code> 값을 뽑아서 전부 더한 <code>total_price</code>를 구하게 된다.</p>
<h3 id="⚠️-참고">⚠️ 참고</h3>
<p><code>JSON_EXTRACT</code>는 JSON 값을 그대로 반환해서, <strong>숫자를 뽑아도 &#39;&quot;100&quot;&#39; 이런 식으로 문자열처럼</strong> 나온다.
그래서 합계를 정확히 구하려면 <code>CAST</code> 또는 <code>-&gt;&gt;</code> 같은 방식으로 숫자로 변환해주는 게 좋다.</p>
<pre><code class="language-sql">SELECT SUM(CAST(JSON_EXTRACT(json_data, &#39;$.price&#39;) AS UNSIGNED)) AS total_price
FROM your_table;

// MySQL 5.7+
SELECT SUM(json_data-&gt;&gt;&#39;$.price&#39;) AS total_price
FROM your_table;</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: Java Lang.]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Java-Lang-6owi8ts5</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Java-Lang-6owi8ts5</guid>
            <pubDate>Mon, 14 Apr 2025 01:37:49 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="java-lang">Java Lang.</h2>
<p>클래스, 생성자, 멤버 변수, 메서드, for문, 연산 등</p>
<h3 id="✅-q1">✅ Q1.</h3>
<pre><code class="language-h=java">class Main {
    public static void main(String[] args) {
        Counter c = new Counter(3);
        int result = c.increase();
        System.out.println(c.val + result);
    }
}

class Counter {
    int val;

    public Counter(int val) {
        this.val = val;
    }

    public int increase() {
        for (int i = 0; i &lt; 2; i++) {
            val += i;
        }
        return val;
    }
}</code></pre>
<blockquote>
<p>🖍️ 8</p>
</blockquote>
<pre><code class="language-java">Counter c = new Counter(3); // val = 3
int result = c.increase();  // val += 0, val += 1 =&gt; val = 4
System.out.println(c.val + result); // 4 + 4 = 8</code></pre>
<h3 id="✅-q2">✅ Q2.</h3>
<pre><code class="language-java">class Main {
    public static void main(String[] args) {
        A a = new A(1);
        a.n = 4;
        System.out.println(a.fun());
    }
}

class A {
    int n;

    public A(int n) {
        this.n = n;
    }

    public int fun() {
        int r = 0;
        for (int i = 1; i &lt; n; i++) {
            r += i * 2;
        }
        return r;
    }
}</code></pre>
<blockquote>
<p>🖍️ 12</p>
</blockquote>
<pre><code class="language-java">A a = new A(1);
a.n = 4;
--------------------------
i from 1 to 3 → r += i * 2  
i = 1 → r = 2  
i = 2 → r = 6  
i = 3 → r = 12</code></pre>
<h3 id="✅-q3">✅ Q3.</h3>
<pre><code class="language-java">class Main {
    public static void main(String[] args) {
        String str1 = &quot;hello&quot;;
        String str2 = &quot;hello&quot;;
        String str3 = &quot;hello world&quot;;
        String str4 = str3.replace(&#39;e&#39;, &#39;a&#39;);

        System.out.println(str1.equals(str2));
        System.out.println(str3.indexOf(&quot;world&quot;));
        System.out.println(str4);
        System.out.println(str4.substring(0,3));
        System.out.println(str2.charAt(0));
    }
}</code></pre>
<blockquote>
<p>🖍️ 
true
6
hallo world
hal
h</p>
</blockquote>
<pre><code class="language-java">System.out.println(str3.indexOf(&quot;world&quot;));
System.out.println(str4.substring(0,3));</code></pre>
<ul>
<li><code>indexOf(&quot;world&quot;)</code>: &quot;world&quot;라는 <strong>문자열이 처음 등장하는 인덱스 위치 반환</strong></li>
<li><code>substring(0, 3)</code>: 인덱스 0부터 시작해서 3 직전까지<strong>(즉, 0, 1, 2 인덱스) 자름.</strong>
<code>&quot;hallo world&quot;</code> → 인덱스 0부터 2까지는 <code>&quot;hal&quot;</code></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[정처기 실기: 21년 기출 용어]]></title>
            <link>https://velog.io/@m_ngyeong/%EC%A0%95%EC%B2%98%EA%B8%B0-%EC%8B%A4%EA%B8%B0-21%EB%85%84-%EA%B8%B0%EC%B6%9C-%EC%9A%A9%EC%96%B4</link>
            <guid>https://velog.io/@m_ngyeong/%EC%A0%95%EC%B2%98%EA%B8%B0-%EC%8B%A4%EA%B8%B0-21%EB%85%84-%EA%B8%B0%EC%B6%9C-%EC%9A%A9%EC%96%B4</guid>
            <pubDate>Fri, 11 Apr 2025 09:01:00 GMT</pubDate>
            <description><![CDATA[<h1 id="정보처리기사-실기">정보처리기사 실기</h1>
<hr>
<h2 id="21년-기출">21년 기출</h2>
<h3 id="3회차">3회차</h3>
<hr>
<h4 id="🖍️-정보-기술-3a">🖍️ 정보 기술 3A</h4>
<ul>
<li><strong>Authentication</strong>: 시스템을 접근하기 전에 접근 시도하는 사용자의 신원을 검증</li>
<li><strong>Authorization</strong>: 검증된 사용자에게 어떤 수준의 권한과 서비스를 허용</li>
<li><strong>Accounting</strong>: 사용자의 자원(시간,정보,위치 등)에 대한 사용 정보를 수집</li>
</ul>
<h4 id="🖍️-데이터-제어어dcl-중-grant">🖍️ 데이터 제어어(DCL) 중 GRANT</h4>
<p>데이터베이스 사용자에게 사용 권한을 부여하는데 사용하는 명령어이다.</p>
<h4 id="🖍️-arp-스푸핑">🖍️ ARP 스푸핑</h4>
<p>근거리 통신망 하에서 ARP 메시지를 이용하여 상대방의 데이터 패킷을 중간에서 가로채는 중간자 공격 기법이다. 이 공격은 데이터 링크 상의 프로토콜인 ARP를 이용하기 때문에 근거리상의 통신에서만 사용할 수 있는 공격이다.</p>
<h4 id="🖍️-제어control-결합도">🖍️ 제어(control) 결합도</h4>
<p>어떤 모듈이 다른 모듈의 내부 논리 조직을 제어하기 위한 목적으로 제어 신호를 이용하여 통신하는 경우의 결합도이다. 하위 모듈에서 상위 모듈로 제어 신호가 이동하여 상위 모듈에게 처리 명령을 부여하는 권리 전도 현상이 발생할 수 있다.</p>
<h4 id="🖍️-osi-7-layer">🖍️ OSI 7 Layer</h4>
<ul>
<li><strong>데이터링크</strong> 계층: 물리계층을 통해 송수신되는 정보의 오류와 흐름을 관리하여 안전한 정보의 전달을 수행할 수 있도록 도와주는 역할</li>
<li><strong>네트워크</strong> 계층: 데이터를 목적지까지 가장 안전하고 빠르게 전달하는 기능</li>
<li><strong>표현</strong> 계층: 수신자에서 데이터의 압축을 풀수 있는 방식으로 된 데이터 압축</li>
</ul>
<h4 id="🖍️-객체지향">🖍️ 객체지향</h4>
<ul>
<li><strong>Aggregation</strong>(집약관계): 클래스들 사이의 전체 또는 부분 같은 관계를 나타내는 것</li>
<li><strong>Generalization</strong>(일반화관계): 한 클래스가 다른 클래스를 포함하는 상위 개념일 때 IS-A관계라하며, 일반화 관계로 모델링함</li>
<li>Accociation(연관관계): 2개 이상 사물이 서로 관련된 관계</li>
<li>Dependency(의존관계): 연관 관계와 같이 한 클래스가 다른 클래스에서 제공하는 기능을 사용할 때 표시</li>
<li>Realization(실체화관계): 인터페이스를 구현받아 추상 메소드를 오버라이딩 함</li>
<li>Composition(합성관계): 부분 객체가 전체 객체에 속하는 관계</li>
</ul>
<h4 id="🖍️-cause-effect-graph-원인-결과-그래프">🖍️ Cause Effect Graph (원인 결과 그래프)</h4>
<p>입력 자료 간의 관계와 출력에 영향을 미치는 상황을 체계적으로 분석 후 효용성이 높은 테스트 케이스를 선정해서 테스트하는 기법이다.</p>
<h4 id="🖍️-des">🖍️ DES</h4>
<p>이것은 미국 NBS (National Bureau of Standards, 현재 NIST)에서 국가 표준으로 정한 암호 알고리즘으로, 64비트 평문을 64비트 암호문으로 암화하는 대칭키 암호 알고리즘이다. 키는 7비트마다 오류검출을 위한 정보가 1비트씩 들어가기 때문에 실질적으로는 56비트이다. 현재는 취약하여 사용되지 않는다.</p>
<h4 id="🖍️-클래스-다이어그램">🖍️ 클래스 다이어그램</h4>
<p>이 다이어그램은 문제 해결을 위한 도메인 구조를 나타내어 보이지 않는 도메인 안의 개념과 같은 추상적인 개념을 기술하기 위해 나타낸 것이다.
또한 소프트웨어의 설계 혹은 완성된 소프트웨어의 구현 설명을 목적으로 사용할 수 있다. 이 다이어그램은 속성(attribute)과 메서드(method)를 포함한다.</p>
<h4 id="🖍️-인덱스">🖍️ 인덱스</h4>
<h3 id="2회차">2회차</h3>
<hr>
<h4 id="🖍️-애드혹-네트워크ad-hoc-network">🖍️ 애드혹 네트워크(Ad-hoc Network)</h4>
<h4 id="🖍️-트랜잭션의-특성-원자성">🖍️ 트랜잭션의 특성: 원자성</h4>
<p>모두 반영되거나 아니면 전혀 반영되지 않아야 하는 특성이다.</p>
<h4 id="🖍️-로킹">🖍️ 로킹</h4>
<p>병행제어기법 중, 접근한 데이터에 대한 연산을 모두 마칠때까지 상호배제하는 기법이다.</p>
<h4 id="🖍️-럼바우-데이터-모델링">🖍️ 럼바우 데이터 모델링</h4>
<ul>
<li><strong>Function</strong> Modeling: 입력값이 출력값일 때 - 자료 흐름도(DFD)</li>
<li><strong>Dynamic</strong> Modeling: 시간에 따라 변하는 것 - 상태 변화도(DFD)</li>
<li><strong>Information</strong> Modeling: 구조 - ER다이어그램(ERD)</li>
</ul>
<h3 id="1회차">1회차</h3>
<hr>
<h4 id="🖍️-rarp-reverse-address-resolution-protocol">🖍️ RARP (Reverse Address Resolution Protocol)</h4>
<p>물리 네트워크(MAC) 주소에 해당하는 IP 주소를 알려주는 프로토콜로 역순 주소 결정 프로토콜이다.</p>
<h4 id="🖍️-wsdl">🖍️ WSDL</h4>
<p>웹 서비스명, 제공 위치, 메세지 포맷, 프로토콜 정보 등 웹 서비스에 대한 상세 정보가 기술된 XML 형식으로 구성된 언어이다.</p>
<h4 id="🖍️-ipc">🖍️ IPC</h4>
<p>공유메모리, 소켓, 세마포어, 메세지 큐 등 프로세스 간 통신하는 기술이다.</p>
<h4 id="🖍️-연산-구조-제약조건">🖍️ 연산, 구조, 제약조건</h4>
<p>데이터 모델 구성요소 3가지:</p>
<ul>
<li>개체 데이터 모델에서는 ( A ) 을/를 이용하여 실제 데이터를 처리하는 작업에 대한 명세를 나타냄</li>
<li>논리 데이터 모델에서는 ( B ) 을/를 어떻게 나타낼 것인지 표현</li>
<li>( C ) 은/는 데이터 무결성 유지를 위한 데이터베이스의 보편적 방법으로 릴레이션의 특정 칼럼에 설정하는 제약을 의미하며, 개체무결성과 참조 무결성 등이 있음</li>
</ul>
<h4 id="🖍️-dac임의적-접근-통제">🖍️ DAC(임의적 접근 통제)</h4>
<p>시스템 객체의 접근을 개인 또는 그룹의 식별자에 기반을 둔 방법, 어떤 종류의 접근 권한을 가진 사용자가 다른 사용자에 자산의 판탄에 따라 권한을 허용하는 접근제어 방식이다.</p>
<h4 id="🖍️-결합도-문제">🖍️ 결합도 문제</h4>
<ul>
<li><strong>내용 결합도</strong> 은/는 <strong>다른 모듈 내부</strong>에 있는 변수나 기능을 다른 모듈에서 사용하는 경우의 결합도</li>
<li><strong>스탬프 결합도</strong> 은/는 <strong>모듈 간의 인터페이스</strong>로 배열이나 객체, 구조 등이 전달되는 경우의 결합도</li>
<li><strong>공통 결합도</strong> 은/는 파라미터가 아닌 <strong>모듈 밖에 선언된 전역 변수를 참조</strong>하고 전역 변수를 갱신하는 식으로 상호작용하는 경우의 결합도</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[정처기 실기: 20년 기출 용어]]></title>
            <link>https://velog.io/@m_ngyeong/%EC%A0%95%EC%B2%98%EA%B8%B0-%EC%8B%A4%EA%B8%B0-20%EB%85%84-%EA%B8%B0%EC%B6%9C-%EC%9A%A9%EC%96%B4</link>
            <guid>https://velog.io/@m_ngyeong/%EC%A0%95%EC%B2%98%EA%B8%B0-%EC%8B%A4%EA%B8%B0-20%EB%85%84-%EA%B8%B0%EC%B6%9C-%EC%9A%A9%EC%96%B4</guid>
            <pubDate>Fri, 11 Apr 2025 05:47:01 GMT</pubDate>
            <description><![CDATA[<h1 id="정보처리기사-실기">정보처리기사 실기</h1>
<hr>
<h2 id="20년-기출">20년 기출</h2>
<h3 id="4회차">4회차</h3>
<hr>
<h4 id="🖍️-즉시갱신-회복-기법">🖍️ 즉시갱신 회복 기법</h4>
<p>데이터베이스의 회복(Recovery) 기법 중 Rollback 시 Redo, Undo가 모두 실행되는 트랜잭션 처리법으로 트랜잭션 수행 중 갱신 결과를 바로 DB에 반영하는 기법이다.</p>
<h4 id="🖍️-스니핑sniffing">🖍️ 스니핑(Sniffing)</h4>
<p><strong>네트워크상에 존재하는 트래픽을 훔쳐보는 행위</strong>로, 주로 자신이 수신해야 하는 정보가 아닌 정보를 받도록 조작하는 행위이다.</p>
<h4 id="🖍️-natnetwork-address-translation">🖍️ NAT(Network Address Translation)</h4>
<p>IP 패킷에서 <strong>외부의 공인 IP주소와 포트 주소에 해당하는 내부 IP주소를 재기록</strong>하여 라우터를 통해 네트워크 트래픽을 주고받는 기술이다.</p>
<h4 id="🖍️-블록체인">🖍️ 블록체인</h4>
<p>분산 컴퓨팅 기술 기반의 데이터 위변조 방지 기술로 P2P방식을 기반으로 하여 소규모 데이터들이 연결되어 형성된 <strong>&#39;블록&#39;</strong>이라는 <strong>분산 데이터 저장 환경</strong>에 관리 대상 데이터를 저장함으로써 누구도 임의로 수정할 수 없고 누구나 변경의 결과를 열람할 수 있게끔 만드는 기술이다.</p>
<h4 id="🖍️-하둡hadoop">🖍️ 하둡(Hadoop)</h4>
<p>오픈 소스 기반으로 한 분산 컴퓨팅 플랫폼으로, 일반 PC급 컴퓨터들로 가상화된 대형 스토리지를 형성하고 그 안에 보관된 <strong>거대한 데이터 세트를 병렬로 처리</strong>할 수 있도록 개발된 자바 소프트웨어 프레임워크로 구글, 야후 등에 적용한 기술이다.</p>
<h4 id="🖍️-프로세스-상태-전의도">🖍️ 프로세스 상태 전의도</h4>
<p><img src="https://velog.velcdn.com/images/m_ngyeong/post/75c3e908-5e62-4a2e-9259-296956b447f7/image.svg" alt=""></p>
<h4 id="🖍️-샘플링-오라클">🖍️ 샘플링 오라클</h4>
<p>테스트 오라클 중 특정한 <strong>몇 개의 입력값에 대해서만</strong> 기대하는 결과를 제공해주는 오라클이다.</p>
<h4 id="🖍️-유닉스unix">🖍️ 유닉스(UNIX)</h4>
<p>데니스 리치와 켄톰슨 등이 함께 벨 연구소를 통해 만든 운영체제이며, 90% 이상 C언어로 구현되어 있고, 시스템 프로그램이 모듈화되어 있어서 다른 하드웨어 기종으로 쉽게 이식 가능하며 계층적 트리 구조를 가짐으로써 통합적인 파일 관리가 용이한 운영체제이다.</p>
<h4 id="🖍️-가용성availability">🖍️ 가용성(Availability)</h4>
<p>정보 보안의 3요소 중 하나로, 인가된 사용자는 원할 때 정보에 접근이 가능해야 한다.</p>
<h3 id="3회차">3회차</h3>
<hr>
<h4 id="🖍️-icmp">🖍️ ICMP</h4>
<p>( )은/는 TCP/IP에서 신뢰성 없는 IP를 대신하여 송신측으로 네트워크의 IP 상태 및 에러 메시지를 전달해주는 프로토콜이다.</p>
<h4 id="🖍️-프로토콜">🖍️ 프로토콜</h4>
<p>심리학자 톰 마릴은 컴퓨터가 메시지를 전달하고 메시지가 제대로 도착했는지 확인하며 도착하지 않았을 경우 메시지를 재전송하는 일련의 방법을 &#39;기술적 은어&#39;를 뜻하는 ( )이라는 용어로 정의했다.</p>
<h4 id="🖍️-÷">🖍️ ÷</h4>
<p>릴레이션 A, B가 있을 때 릴레이션 B 조건에 맞는 것들만 릴레이션 A에서 튜플을 꺼내 프로젝션하는 관계대수의 기호이다.</p>
<h4 id="🖍️-헝가리안-표기법hungarian-notation">🖍️ 헝가리안 표기법(Hungarian Notation)</h4>
<p>식별자 표기 시 접두어에 자료형을 붙이는 표기법이다.</p>
<h4 id="🖍️-데이터베이스에서-스키마schema">🖍️ 데이터베이스에서 스키마(Schema)</h4>
<p>데이터베이스의 전체적인 구조와 제약조건에 대한 명세로, 내부 스키마와 개념 스키마, 외부 스키마로 나뉜다.</p>
<h4 id="🖍️-eai-유형">🖍️ EAI 유형</h4>
<ul>
<li>포인트 투 포인트(Point-to-point)</li>
<li>허브 앤 스포크(Hub &amp; Spoke)</li>
<li>메세지 버스(Message bus) 유형</li>
<li>하이브리드(Hybrid) 유형</li>
</ul>
<h4 id="🖍️-생성자">🖍️ 생성자</h4>
<p>해당 클래스의 객체가 생성될 때 <strong>자동으로 호출</strong>되는 특수한 종류의 메서드이다.</p>
<h3 id="2회차">2회차</h3>
<hr>
<h4 id="🖍️-목표-복구-시간rto-recovery-time-objective">🖍️ 목표 복구 시간(RTO; Recovery Time Objective)</h4>
<h4 id="🖍️-ipsec">🖍️ IPSec</h4>
<p>네트워크 계층(network layer, 3계층)인 인터넷 프로토콜(IP)에서 &#39;암호화&#39;, &#39;인증&#39;, &#39;키 관리&#39;를 통해 보완성을 제공해 주는 표준화된 기술이다.</p>
<h4 id="🖍️-observer">🖍️ Observer</h4>
<p>한 객체의 상태가 바뀌면 그 객체에 의존하는 다른 객체들한테 연락이 가고 자동으로 내용이 갱신되는 방식으로 일대다(one-to-many) 의존성을 가지는 패턴이다.
서로 상호작용을 하는 객체 사이에서는 가능하면 느슨하게 결합(Loose coupling)하는 디자인을 사용해야 한다.</p>
<h4 id="🖍️-soap">🖍️ SOAP</h4>
<p>( )은/는 HTTP 등의 프로토콜을 이용하여 XML 기반의 메시지를 교환하는 프로토콜로, Envelope-Header-Body 주요 3요소로 구성된다. ( )은/는 유사한 기능을 하는 RESTful로 대체될 수 있다.</p>
<h4 id="🖍️-linked-open-data">🖍️ Linked Open Data</h4>
<ul>
<li>전세계 오픈된 정보를 하나로 묶는 방식</li>
<li>Linked data와 Open data의 합성어</li>
<li>URI(Uniform Resource Identifier)를 사용</li>
<li>RESTful 방식으로 볼 수 있으며, 링크 기능이 강조된 시멘틱 웹에 속하는 기술</li>
</ul>
<h4 id="🖍️-개념절-설계-→-논리적-설계-→-물리적-설계">🖍️ 개념절 설계 → 논리적 설계 → 물리적 설계</h4>
<p>DB 설계(모델링) 과정: 요구사항 분석 → <strong>개념절 설계 → 논리적 설계 → 물리적 설계</strong> → 구현</p>
<h4 id="🖍️-형상-관리">🖍️ 형상 관리</h4>
<p>CVS, SVN, Clear Case 등이 있다.</p>
<h3 id="1회차">1회차</h3>
<hr>
<h4 id="🖍️-구문-의미-타이밍">🖍️ 구문, 의미, 타이밍</h4>
<p>프로토콜을 구성하는 대표적인 세가지 요소</p>
<h4 id="🖍️-원자성-일관성-독립성-지속성">🖍️ 원자성, 일관성, 독립성, 지속성</h4>
<p>데이터베이스 트랜잭션의 4가지 속성</p>
<h4 id="🖍️-랜드-어택land-attack">🖍️ 랜드 어택(Land Attack)</h4>
<p>패킷의 출발지 주소(Address)나 포트(Port)를 임의로 변경하여 출발지와 목적지 주소[포트]를 통일하게 함으로써, 공격 대상 컴퓨터의 실행 속도를 느리게 하거나 동작을 마비시켜 서비스 거부 상태에 빠지도록 하는 공격이다.</p>
<h4 id="🖍️-물리-계층">🖍️ 물리 계층</h4>
<p>OSI 7계층에서 ( )는 전송에 필요한 두 장치 간의 실제 접속과 절단 등 기계적, 전기적, 기능적, 절차적 특성에 대한 규칙을 정의한다. 단위(PDU)는 &#39;비트&#39;를 사용한다.</p>
<h4 id="🖍️-처리량-응답-시간-경과-시간-자원-사용률">🖍️ 처리량, 응답 시간, 경과 시간, 자원 사용률</h4>
<p>애플리케이션 성능을 측정</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: Java Lang.]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Java-Lang-w39ftu3s</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Java-Lang-w39ftu3s</guid>
            <pubDate>Tue, 08 Apr 2025 02:36:53 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="java-lang">Java Lang.</h2>
<h3 id="✅-오버라이딩">✅ 오버라이딩</h3>
<pre><code class="language-java">class A {
    void print() {
        System.out.println(&quot;A&quot;);
    }
}

class B extends A {
    void print() {
        System.out.println(&quot;B&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        A obj = new B();
        obj.print();
    }
}</code></pre>
<blockquote>
<p>🖍️ B</p>
</blockquote>
<ul>
<li><code>obj.print();</code> → B의 print()</li>
</ul>
<h3 id="✅-오버로딩">✅ 오버로딩</h3>
<pre><code class="language-java">class Calc {
    int add(int a, int b) {
        return a + b;
    }

    double add(double a, double b) {
        return a + b;
    }
}

public class Main {
    public static void main(String[] args) {
        Calc c = new Calc();
        System.out.println(c.add(2, 3));
        System.out.println(c.add(2.5, 1.5));
    }
}</code></pre>
<blockquote>
<p>🖍️ 
5
4.0</p>
</blockquote>
<ul>
<li><code>c.add(2, 3)</code> → <code>int add(int a, int b){}</code> → 5  </li>
<li><code>c.add(2.5, 1.5)</code> → <code>double add(double a, double b){}</code> → 4.0</li>
</ul>
<h3 id="✅-equals-vs-">✅ equals() vs ==</h3>
<pre><code class="language-java">public class Main {
    public static void main(String[] args) {
        String s1 = new String(&quot;hello&quot;);
        String s2 = new String(&quot;hello&quot;);
        System.out.println(s1 == s2);
        System.out.println(s1.equals(s2));
    }
}</code></pre>
<blockquote>
<p>🖍️ 
false
true</p>
</blockquote>
<ul>
<li><code>s1 == s2</code> → false (다른 객체)  </li>
<li><code>s1.equals(s2)</code> → true (내용 비교)</li>
</ul>
<h3 id="✅-업캐스팅과-다형성">✅ 업캐스팅과 다형성</h3>
<pre><code class="language-java">class Animal {
    void sound() {
        System.out.println(&quot;Some sound&quot;);
    }
}

class Dog extends Animal {
    void sound() {
        System.out.println(&quot;Bark&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.sound();
    }
}</code></pre>
<blockquote>
<p>🖍️ Bark</p>
</blockquote>
<ul>
<li><code>Animal a = new Dog();</code></li>
<li><code>a.sound();</code> → Dog의 오버라이딩된 메서드 호출됨 → &quot;Bark&quot;</li>
</ul>
<h3 id="✅-static-메서드-하이딩">✅ static 메서드 하이딩</h3>
<pre><code class="language-java">class Parent {
    static void greet() {
        System.out.println(&quot;Hello from Parent&quot;);
    }
}

class Child extends Parent {
    static void greet() {
        System.out.println(&quot;Hello from Child&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Parent p = new Child();
        p.greet();
    }
}</code></pre>
<blockquote>
<p>🖍️ Hello from Parent</p>
</blockquote>
<ul>
<li><code>Parent p = new Child();</code></li>
<li><code>p.greet();</code> → <code>static</code>은 클래스 타입 기준 → &quot;Hello from Parent&quot;</li>
</ul>
<h3 id="✅-추상-클래스와-구현">✅ 추상 클래스와 구현</h3>
<pre><code class="language-java">abstract class Shape {
    abstract void draw();
}

class Circle extends Shape {
    void draw() {
        System.out.println(&quot;Draw Circle&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Shape s = new Circle();
        s.draw();
    }
}</code></pre>
<blockquote>
<p>🖍️ Draw Circle</p>
</blockquote>
<ul>
<li><code>Shape s = new Circle();</code></li>
<li><code>s.draw();</code> → &quot;Draw Circle&quot;</li>
</ul>
<h3 id="❌-생성자-실행-순서">❌ 생성자 실행 순서</h3>
<pre><code class="language-java생성자">class Super {
    Super() {
        System.out.println(&quot;Super constructor&quot;);
    }
}

class Sub extends Super {
    Sub() {
        System.out.println(&quot;Sub constructor&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Sub obj = new Sub();
    }
}</code></pre>
<blockquote>
<p>🖍️ 
Super constructor
Sub constructor</p>
</blockquote>
<ul>
<li><strong>Sub 객체 생성 시 → Super → Sub 순으로 호출됨</strong></li>
</ul>
<h3 id="❌-instanceof-연산자">❌ instanceof 연산자</h3>
<pre><code class="language-java">class Animal {}
class Cat extends Animal {}

public class Main {
    public static void main(String[] args) {
        Animal a = new Cat();
        System.out.println(a instanceof Animal);
        System.out.println(a instanceof Cat);
    }
}</code></pre>
<blockquote>
<p>🖍️ 
true
true</p>
</blockquote>
<ul>
<li><code>Animal a = new Cat();</code></li>
<li><code>a instanceof Animal</code> → true  </li>
<li><code>a instanceof Cat</code> → true</li>
</ul>
<h3 id="✅-변수-하이딩">✅ 변수 하이딩</h3>
<pre><code class="language-java">class Parent {
    int x = 10;
}

class Child extends Parent {
    int x = 20;
}

public class Main {
    public static void main(String[] args) {
        Parent p = new Child();
        System.out.println(p.x);
    }
}</code></pre>
<blockquote>
<p>🖍️ 10</p>
</blockquote>
<ul>
<li><code>Parent p = new Child();</code></li>
<li><code>p.x</code> → 10 (Parent 기준으로 접근됨)</li>
</ul>
<h3 id="✅-인터페이스와-다형성">✅ 인터페이스와 다형성</h3>
<pre><code class="language-java">interface Drawable {
    void draw();
}

class Rectangle implements Drawable {
    public void draw() {
        System.out.println(&quot;Drawing Rectangle&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Drawable d = new Rectangle();
        d.draw();
    }
}</code></pre>
<blockquote>
<p>🖍️ Drawing Rectangle</p>
</blockquote>
<hr>
<h2 id="instanceof">instanceof</h2>
<ul>
<li><code>instanceof</code> 는 <strong>실제 객체 기준</strong>으로 판별한다(타입 일치 여부)</li>
<li><code>instanceof null</code> → 항상 false</li>
<li>인터페이스도 <code>instanceof</code> 가능</li>
<li><strong>클래스끼리는 상속 관계가 아닌 경우 false</strong></li>
</ul>
<h3 id="❌-업캐스팅-후-instanceof">❌ 업캐스팅 후 instanceof</h3>
<pre><code class="language-java">class Animal {}
class Dog extends Animal {}
class Cat extends Animal {}

public class Main {
    public static void main(String[] args) {
        Animal a = new Dog();
        System.out.println(a instanceof Dog);
        System.out.println(a instanceof Cat);
        System.out.println(a instanceof Animal);
    }
}</code></pre>
<blockquote>
<p>🖍️
true
false
true</p>
</blockquote>
<ul>
<li><code>a</code>는 실제로 <code>Dog</code> 객체 → <code>instanceof Dog</code> → true</li>
<li><code>a</code>는 <code>Cat</code>은 아님 → <code>instanceof Cat</code> → false</li>
<li><code>Dog</code>는 <code>Animal</code>을 상속 → <code>instanceof Animal</code> → true</li>
</ul>
<h3 id="❌-인터페이스-instanceof">❌ 인터페이스 instanceof</h3>
<pre><code class="language-java">interface Eater {}
class Human implements Eater {}
class Robot {}  // Robot은 Object를 상속하고 있음

public class Main {
    public static void main(String[] args) {
        Object obj = new Human();
        System.out.println(obj instanceof Eater);
        System.out.println(obj instanceof Human);
        System.out.println(obj instanceof Robot);
    }
}</code></pre>
<blockquote>
<p>🖍️ 
true
true
false</p>
</blockquote>
<ul>
<li><code>Human</code>은 <code>Eater</code> 구현 → <code>instanceof Eater</code> → true</li>
<li><code>obj</code>는 <code>Human</code>이므로 <code>instanceof Human</code> → true</li>
<li><strong><code>Human</code>은 <code>Robot</code> 아님 → false</strong>
<code>new Robot() instanceof Object  // true</code>
<code>Object obj = new Human();</code> → <code>obj</code>는 실제로 <code>Human</code> 객체
→ <strong><code>Human</code>과 <code>Robot</code>은 아무 관계 없음</strong></li>
</ul>
<h3 id="❌-null-객체에-instanceof">❌ null 객체에 instanceof</h3>
<pre><code class="language-java">class A {}
public class Main {
    public static void main(String[] args) {
        A a = null;
        System.out.println(a instanceof A);
    }
}</code></pre>
<blockquote>
<p>🖍️ false</p>
</blockquote>
<ul>
<li><code>instanceof</code>는 <code>null</code>이면 무조건 false</li>
<li>타입과 상관없음</li>
</ul>
<hr>
<h2 id="다형성--타입-캐스팅-문제">다형성 &amp; 타입 캐스팅 문제</h2>
<h3 id="✅-업캐스팅과-메서드-호출">✅ 업캐스팅과 메서드 호출</h3>
<pre><code class="language-java">class Animal {
    void speak() {
        System.out.println(&quot;Animal speaks&quot;);
    }
}

class Cat extends Animal {
    void speak() {
        System.out.println(&quot;Meow&quot;);
    }

    void jump() {
        System.out.println(&quot;Cat jumps&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Animal a = new Cat();
        a.speak();
        // a.jump();  // 컴파일 에러 발생 여부?
    }
}</code></pre>
<blockquote>
<p>🖍️ Meow</p>
</blockquote>
<ul>
<li><code>Animal a = new Cat();</code>
<code>a.speak();</code>: Cat의 오버라이딩된 메서드 호출</li>
<li><code>a.jump();</code>: a.jump() 는 업캐스팅된 참조로는 불가 → 컴파일 에러</li>
</ul>
<h3 id="✅-다운캐스팅">✅ 다운캐스팅</h3>
<pre><code class="language-java">class Parent {
    void show() {
        System.out.println(&quot;Parent&quot;);
    }
}

class Child extends Parent {
    void show() {
        System.out.println(&quot;Child&quot;);
    }

    void onlyChild() {
        System.out.println(&quot;Child specific method&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Parent p = new Child(); // 업캐스팅
        p.show();                // 오버라이딩된 Child.show()

        Child c = (Child) p;    // 다운캐스팅 (정상)
        c.onlyChild();            // Child의 전용 메서드
    }
}</code></pre>
<blockquote>
<p>🖍️ 
Child
Child specific method</p>
</blockquote>
<h3 id="❌-잘못된-다운캐스팅">❌ 잘못된 다운캐스팅</h3>
<pre><code class="language-java">class A {}
class B extends A {}
class C extends A {}

public class Main {
    public static void main(String[] args) {
        A obj = new C();  // 실제로는 C 타입
        B b = (B) obj;    // C는 B의 하위 클래스 아님 → ClassCastException 발생
        System.out.println(&quot;Cast success&quot;);
    }
}</code></pre>
<blockquote>
<p>🖍️ ❗ 런타임 에러 (ClassCastException) 발생</p>
</blockquote>
<pre><code class="language-bash">Exception in thread &quot;main&quot; java.lang.ClassCastException: C cannot be cast to B</code></pre>
<h3 id="✅-다형성과-배열">✅ 다형성과 배열</h3>
<pre><code class="language-java">class Vehicle {
    void run() {
        System.out.println(&quot;Vehicle runs&quot;);
    }
}

class Bike extends Vehicle {
    void run() {
        System.out.println(&quot;Bike runs fast&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Vehicle[] list = { new Vehicle(), new Bike() };
        for (Vehicle v : list) {
            v.run();
        }
    }
}</code></pre>
<blockquote>
<p>🖍️ 
Vehicle runs
Bike runs fast</p>
</blockquote>
<h4 id="배열-선언">배열 선언:</h4>
<pre><code class="language-java">Vehicle[] list = { new Vehicle(), new Bike() };</code></pre>
<ul>
<li>list는 Vehicle 타입의 배열이지만, 
그 안에는 Vehicle 객체와 업캐스팅된 Bike 객체가 있음.</li>
<li>즉, 내부적으로는 이렇게 저장돼 있음:<pre><code class="language-java">list[0] → new Vehicle()
list[1] → new Bike()  ← Bike가 Vehicle로 업캐스팅됨</code></pre>
<h4 id="반복문-실행">반복문 실행:</h4>
<pre><code class="language-java">for (Vehicle v : list) {
  v.run();
}</code></pre>
</li>
<li>첫 번째 반복: <code>v = new Vehicle()</code> → <code>v.run()</code> → Vehicle runs</li>
<li>두 번째 반복: <code>v = new Bike()</code>
v는 Vehicle 타입으로 보이지만, 실제 객체는 Bike이므로
→ 오버라이딩된 <code>Bike.run()</code>이 호출됨
→ Bike runs fast</li>
</ul>
<h3 id="❌-instanceof를-활용한-안전한-캐스팅">❌ instanceof를 활용한 안전한 캐스팅</h3>
<pre><code class="language-java">class Animal {}
class Dog extends Animal {
    void bark() {
        System.out.println(&quot;Woof&quot;);
    }
}

class Cat extends Animal {}

public class Main {
    public static void main(String[] args) {
        Animal a = new Cat();

        if (a instanceof Dog) {
            Dog d = (Dog) a;
            d.bark();
        } else {
            System.out.println(&quot;Not a Dog&quot;);
        }
    }
}</code></pre>
<blockquote>
<p>🖍️ Not a Dog</p>
</blockquote>
<ul>
<li><code>a</code>는 <code>Cat</code>이므로 <code>instanceof Dog</code>→ false
→ else 블록 실행됨</li>
</ul>
<h3 id="✅-정적-메서드hiding-vs-인스턴스-메서드오버라이딩">✅ 정적 메서드(hiding) vs 인스턴스 메서드(오버라이딩)</h3>
<pre><code class="language-java">class Base {
    static void greet() {
        System.out.println(&quot;Hello from Base&quot;);
    }

    void say() {
        System.out.println(&quot;Base says hi&quot;);
    }
}

class Derived extends Base {
    static void greet() {
        System.out.println(&quot;Hello from Derived&quot;);
    }

    void say() {
        System.out.println(&quot;Derived says hi&quot;);
    }
}

public class Main {
    public static void main(String[] args) {
        Base b = new Derived();
        b.greet(); 
        b.say();   
    }
}</code></pre>
<blockquote>
<p>🖍️ 
Hello from Base
Derived says hi</p>
</blockquote>
<pre><code class="language-java">Base b = new Derived();
b.greet();  // 정적 메서드 → 참조 변수 타입 기준 → Base.greet()
b.say();    // 인스턴스 메서드 → 실제 객체 기준 → Derived.say()</code></pre>
<ul>
<li><code>greet()</code>은 static → 오버라이딩 아님 → Base 기준</li>
<li><code>say()</code>는 오버라이딩 → Derived 기준</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: Python Lang.]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Python-Lang-5iy0s8yt</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Python-Lang-5iy0s8yt</guid>
            <pubDate>Tue, 08 Apr 2025 01:27:40 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="python-lang">Python Lang.</h2>
<h3 id="❌-딕셔너리-키와-in-연산자">❌ 딕셔너리 키와 in 연산자</h3>
<pre><code class="language-python">d = {&#39;a&#39;: 1, &#39;b&#39;: 2}
print(&#39;a&#39; in d, 1 in d)</code></pre>
<blockquote>
<p>🖍️ True False</p>
</blockquote>
<ul>
<li><code>&#39;a&#39; in d</code> → True (키 체크)</li>
<li><code>1 in d</code> → False (값은 아님!)</li>
</ul>
<h3 id="✅-set의-중복-제거--정렬">✅ set의 중복 제거 + 정렬</h3>
<pre><code class="language-python">s = set([3, 1, 2, 3, 2])
print(sorted(s))</code></pre>
<blockquote>
<p>🖍️ [1,2,3]</p>
</blockquote>
<ul>
<li><code>set</code>은 중복을 제거함</li>
</ul>
<h3 id="❌-딕셔너리-값-기준-정렬--lambda">❌ 딕셔너리 값 기준 정렬 : lambda</h3>
<pre><code class="language-python">d = {&#39;apple&#39;: 3, &#39;banana&#39;: 1, &#39;cherry&#39;: 2}
print(sorted(d.items(), key=lambda x: x[1]))</code></pre>
<blockquote>
<p>🖍️ [(&#39;banana&#39;, 1), (&#39;cherry&#39;, 2), (&#39;apple&#39;, 3)]</p>
</blockquote>
<ul>
<li><code>d.items()</code> → <code>[(&#39;apple&#39;, 3), (&#39;banana&#39;, 1), (&#39;cherry&#39;, 2)]</code></li>
<li>값 기준 정렬 → <code>[(&#39;banana&#39;, 1), (&#39;cherry&#39;, 2), (&#39;apple&#39;, 3)]</code></li>
</ul>
<h3 id="❌-enumerate와-unpacking">❌ enumerate와 unpacking</h3>
<pre><code class="language-python">lst = [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;]
for idx, val in enumerate(lst, start=1):
    if idx == 2:
        print(val)</code></pre>
<blockquote>
<p>🖍️ &#39;b&#39;</p>
</blockquote>
<ul>
<li><code>for idx, val in enumerate(lst, start=1):</code>
구문에 의해 index는 1부터 시작</li>
<li><code>idx=2</code>일 때 <code>val → &#39;b&#39;</code></li>
</ul>
<h3 id="❌-set-연산">❌ set 연산</h3>
<pre><code class="language-python">a = {1, 2, 3}
b = {3, 4, 5}
print(a &amp; b, a | b)</code></pre>
<blockquote>
<p>🖍️ {3} {1, 2, 3, 4, 5}</p>
</blockquote>
<ul>
<li><code>a &amp; b</code> → <code>{3}</code></li>
<li><code>a | b</code> → <code>{1, 2, 3, 4, 5}</code></li>
</ul>
<h3 id="❌-딕셔너리-get-메서드">❌ 딕셔너리 .get() 메서드</h3>
<pre><code class="language-python">d = {&#39;x&#39;: 10}
print(d.get(&#39;x&#39;), d.get(&#39;y&#39;), d.get(&#39;y&#39;, &#39;N/A&#39;))</code></pre>
<blockquote>
<p>🖍️ 10 None &#39;N/A&#39;</p>
</blockquote>
<ul>
<li><code>d.get(&#39;x&#39;)</code> → 10</li>
<li><code>d.get(&#39;y&#39;)</code> → None</li>
<li><code>d.get(&#39;y&#39;, &#39;N/A&#39;)</code> → &#39;N/A&#39;</li>
</ul>
<h3 id="✅--lambda와-map">✅  lambda와 map</h3>
<pre><code class="language-python">nums = [1, 2, 3]
result = list(map(lambda x: x * 2, nums))
print(result)</code></pre>
<blockquote>
<p>🖍️ [2, 4, 6]</p>
</blockquote>
<h3 id="✅-filter와-lambda">✅ filter와 lambda</h3>
<pre><code class="language-python">nums = [0, 1, 2, 3, 4]
result = list(filter(lambda x: x % 2 == 0, nums))
print(result)</code></pre>
<blockquote>
<p>🖍️ [0, 2, 4]</p>
</blockquote>
<ul>
<li>짝수만 출력</li>
</ul>
<h3 id="❌-set의-불변성">❌ set의 불변성</h3>
<pre><code class="language-python">s = {1, 2, 3}
try:
    s.add([4, 5])
except Exception as e:
    print(type(e).__name__)</code></pre>
<blockquote>
<p>🖍️ TypeError</p>
</blockquote>
<ul>
<li>리스트는 hashable 아님 → <code>TypeError</code></li>
<li>리스트는 set에 못 들어감</li>
</ul>
<h3 id="✅-sorted의-key-함수와-reverse">✅ sorted의 key 함수와 reverse</h3>
<pre><code class="language-python">words = [&quot;apple&quot;, &quot;banana&quot;, &quot;kiwi&quot;]
print(sorted(words, key=lambda x: len(x), reverse=True))</code></pre>
<blockquote>
<p>🖍️ [&quot;banana&quot;, &quot;apple&quot;, &quot;kiwi&quot;]</p>
</blockquote>
<ul>
<li><code>key=lambda x: len(x)</code> → <code>[5, 6, 4]</code></li>
<li><code>sorted(words)</code> → <code>[&quot;kiwi&quot;, &quot;apple&quot;, &quot;banana&quot;]</code></li>
<li><code>reverse=True</code> → <code>[&quot;banana&quot;, &quot;apple&quot;, &quot;kiwi&quot;]</code></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: C Lang. ]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-C-Lang-sue1rypu</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-C-Lang-sue1rypu</guid>
            <pubDate>Tue, 08 Apr 2025 00:50:49 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="c-lang">C Lang.</h2>
<h3 id="✅-구조체-포인터-체이닝">✅ 구조체 포인터 체이닝</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Node {
    int data;
    struct Node *next;
};

int main() {
    struct Node n3 = {30, NULL};
    struct Node n2 = {20, &amp;n3};
    struct Node n1 = {10, &amp;n2};

    struct Node *head = &amp;n1;
    printf(&quot;%d\n&quot;, head-&gt;next-&gt;next-&gt;data);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 30</p>
</blockquote>
<ul>
<li><code>head-&gt;next-&gt;next-&gt;data</code> -&gt; <code>n1 -&gt; n2 -&gt; n3.data</code></li>
</ul>
<h3 id="✅-연결-리스트를-통한-합계-계산">✅ 연결 리스트를 통한 합계 계산</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

struct Node {
    int value;
    struct Node *next;
};

int main() {
    struct Node *a = malloc(sizeof(struct Node));
    struct Node *b = malloc(sizeof(struct Node));
    struct Node *c = malloc(sizeof(struct Node));

    a-&gt;value = 5; a-&gt;next = b;
    b-&gt;value = 10; b-&gt;next = c;
    c-&gt;value = 15; c-&gt;next = NULL;

    struct Node *ptr = a;
    int sum = 0;
    while (ptr != NULL) {
        sum += ptr-&gt;value;
        ptr = ptr-&gt;next;
    }

    printf(&quot;%d\n&quot;, sum);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 30</p>
</blockquote>
<ul>
<li>sum = 5 + 10 + 15 = 30</li>
</ul>
<h3 id="❌-구조체-포인터-비교">❌ 구조체 포인터 비교</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Item {
    int id;
    struct Item *link;
};

int main() {
    struct Item a = {1, NULL};
    struct Item b = {2, &amp;a};
    struct Item c = {3, &amp;b};

    struct Item *ptr = &amp;c;

    if (ptr-&gt;link-&gt;link == NULL)
        printf(&quot;End\n&quot;);
    else
        printf(&quot;Not End\n&quot;);

    return 0;
}</code></pre>
<blockquote>
<p>🖍️ Not End</p>
</blockquote>
<pre><code class="language-c">ptr = &amp;c  
ptr-&gt;link = &amp;b  
ptr-&gt;link-&gt;link = &amp;a  
→ &amp;a != NULL → &quot;Not End&quot;</code></pre>
<h3 id="❌-문자열-필터링-포인터-포함">❌ 문자열 필터링 (포인터 포함)</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

struct Word {
    char str[20];
    struct Word *next;
};

int main() {
    struct Word w1 = {&quot;cat&quot;, NULL};
    struct Word w2 = {&quot;apple&quot;, &amp;w1};
    struct Word w3 = {&quot;banana&quot;, &amp;w2};

    struct Word *ptr = &amp;w3;

    while (ptr != NULL) {
        if (strchr(ptr-&gt;str, &#39;a&#39;) != NULL &amp;&amp; strlen(ptr-&gt;str) &gt; 4)
            printf(&quot;%s\n&quot;, ptr-&gt;str);
        ptr = ptr-&gt;next;
    }

    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 
banana
apple</p>
</blockquote>
<ul>
<li><code>strchr(ptr-&gt;str, &#39;a&#39;) != NULL</code>: 문자열에 &#39;a&#39;가 포함</li>
<li><code>strlen(ptr-&gt;str) &gt; 4</code>: 문자열의 길이 &gt; 4</li>
<li>&quot;cat&quot; : 문자열에 &#39;a&#39;는 포함되지만 문자열의 길이 4가 되지 않음 ∴ false</li>
<li>&quot;apple&quot; : 문자열에 &#39;a&#39;가 포함되면서 동시에 문자열의 길이가 4가 넘음 ∴ true</li>
<li>&quot;banana&quot;: &quot;apple&quot;가 같은 이유 ∴ true</li>
</ul>
<h3 id="✅-연결-구조에서-조건-필터--합산">✅ 연결 구조에서 조건 필터 + 합산</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Data {
    int num;
    struct Data *next;
};

int main() {
    struct Data d3 = {11, NULL};
    struct Data d2 = {6, &amp;d3};
    struct Data d1 = {4, &amp;d2};

    struct Data *cur = &amp;d1;
    int sum = 0;

    while (cur) {
        if (cur-&gt;num % 2 == 0)
            sum += cur-&gt;num;
        cur = cur-&gt;next;
    }

    printf(&quot;%d\n&quot;, sum);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 10</p>
</blockquote>
<ul>
<li>구조체 <code>Data</code>는 <code>int num</code>과 다음 노드를 가리키는 포인터 <code>*next</code>를 가지고 있어 → <strong>단일 연결 리스트 구조</strong></li>
<li><code>d1 -&gt; d2 -&gt; d3</code> 순서로 연결되어 있고, 값은 각각 <code>4 → 6 → 11</code></li>
<li><code>d1 % 2 = 4 % 2 == 0</code> -&gt; <code>sum += 4</code></li>
<li><code>d2 % 2 = 6 % 2 == 0</code> -&gt; <code>sum = 4 + 6</code></li>
<li><code>d3 % 2 = 11 % 2 != 0</code> </li>
</ul>
<h3 id="❌-이중-포인터를-이용한-값-변경">❌ 이중 포인터를 이용한 값 변경</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

void update(int **pp) {
    **pp = 99;
}

int main() {
    int a = 5;
    int *p = &amp;a;
    update(&amp;p);
    printf(&quot;%d\n&quot;, a);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️  99</p>
</blockquote>
<ul>
<li><code>int *p = &amp;a;</code> → 포인터 <code>p</code>는 <code>a</code>의 주소를 가리킴</li>
<li><code>update(&amp;p);</code> → <code>p</code>의 주소를 전달 → 즉, <code>pp</code>는 <code>int**</code> → &quot;포인터를 가리키는 포인터&quot;</li>
<li><code>*pp</code>는 <code>p</code>, 즉 <code>&amp;a</code></li>
<li><code>**pp</code>는 <code>*(&amp;a)</code> → 결국 <code>a</code>
∴ <code>**pp = 99</code> → <code>a = 99</code></li>
</ul>
<h3 id="✅-malloc과-구조체-배열-동적-생성">✅ malloc과 구조체 배열 동적 생성</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

struct Box {
    int size;
};

int main() {
    struct Box *arr = malloc(3 * sizeof(struct Box));
    arr[0].size = 10;
    arr[1].size = 20;
    arr[2].size = 30;

    int total = 0;
    for (int i = 0; i &lt; 3; i++) {
        total += arr[i].size;
    }

    printf(&quot;%d\n&quot;, total);
    free(arr);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️  60
total = 10 + 20 + 30</p>
</blockquote>
<h3 id="✅-구조체-내-포인터를-이용한-문자열-복사">✅ 구조체 내 포인터를 이용한 문자열 복사</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

struct Person {
    char *name;
};

int main() {
    struct Person p;
    p.name = malloc(20);

    strcpy(p.name, &quot;Charlie&quot;);  // 문자열 복사
    printf(&quot;%s\n&quot;, p.name);
    free(p.name);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ Charlie</p>
</blockquote>
<h3 id="✅-포인터를-이용한-연결-리스트-길이-구하기">✅ 포인터를 이용한 연결 리스트 길이 구하기</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Node {
    int val;
    struct Node *next;
};

int main() {
    struct Node n3 = {3, NULL};
    struct Node n2 = {2, &amp;n3};
    struct Node n1 = {1, &amp;n2};

    struct Node *ptr = &amp;n1;
    int count = 0;

    while (ptr) {
        count++;
        ptr = ptr-&gt;next;
    }

    printf(&quot;%d\n&quot;, count);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 3</p>
</blockquote>
<ul>
<li>노드 3개</li>
</ul>
<h3 id="✅-malloc--연결-리스트-초기화-및-조건-검사">✅ malloc + 연결 리스트 초기화 및 조건 검사</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

struct Animal {
    char name[20];
    struct Animal *next;
};

int main() {
    struct Animal *a = malloc(sizeof(struct Animal));
    struct Animal *b = malloc(sizeof(struct Animal));

    strcpy(a-&gt;name, &quot;dog&quot;);
    a-&gt;next = b;

    strcpy(b-&gt;name, &quot;cat&quot;);
    b-&gt;next = NULL;

    struct Animal *cur = a;
    while (cur != NULL) {
        if (strcmp(cur-&gt;name, &quot;cat&quot;) == 0)
            printf(&quot;Meow\n&quot;);
        cur = cur-&gt;next;
    }

    free(a);
    free(b);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ Meow</p>
</blockquote>
<ul>
<li><code>if (strcmp(cur-&gt;name, &quot;cat&quot;) == 0)</code> </li>
<li><blockquote>
<p><code>if (strcmp(&quot;dog&quot;, &quot;cat&quot;) == 0)</code></p>
</blockquote>
</li>
<li><blockquote>
<p>not 0 ∴ <code>cur = cur-&gt;next;</code></p>
</blockquote>
</li>
<li><code>if (strcmp(&quot;cat&quot;, &quot;cat&quot;) == 0)</code>
∴ strcmp == 0 </li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: Python Lang.]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Python-Lang-shzfch0l</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Python-Lang-shzfch0l</guid>
            <pubDate>Mon, 07 Apr 2025 08:58:43 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="python-lang">Python Lang.</h2>
<h3 id="✅-리스트-슬라이싱--참조">✅ 리스트 슬라이싱 + 참조</h3>
<pre><code class="language-python">a = [1, 2, 3, 4]
b = a[1:3]
b[0] = 99
print(a[1])</code></pre>
<blockquote>
<p>🖍️ 2</p>
</blockquote>
<ul>
<li><code>b = a[1:3]</code> → <code>b = [2, 3]</code></li>
<li><code>b[0] = 99</code>  → <code>b = [99, 3]</code></li>
</ul>
<h3 id="❌-리스트-곱하기-vs-리스트-컴프리헨션">❌ 리스트 곱하기 vs 리스트 컴프리헨션</h3>
<pre><code class="language-python">a = [[0] for _ in range(3)]
a[0][0] = 100
print(a)</code></pre>
<blockquote>
<p>🖍️ <code>[[100], [100], [100]]</code></p>
</blockquote>
<ul>
<li><code>a = [[0] for _ in range(3)]</code> → <code>a =[[0], [0], [0]]</code>
각각 독립적인 리스트</li>
<li><code>a[0][0] = 100</code> → <code>[[100], [0], [0]]</code>
👉 <strong>이건 <code>[[0]] * 3</code> 일 때 생기는 참조 공유 현상과 다름!</strong></li>
</ul>
<h3 id="✅-문자열-불변성">✅ 문자열 불변성</h3>
<pre><code class="language-python">s = &quot;hello&quot;
t = s
s = s.upper()
print(t)</code></pre>
<blockquote>
<p>🖍️ hello</p>
</blockquote>
<ul>
<li><code>t = hello</code></li>
<li><code>s = HELLO</code></li>
</ul>
<h3 id="✅-set과-리스트-변환">✅ set과 리스트 변환</h3>
<pre><code class="language-python">a = list(set([1, 2, 2, 3]))
a.sort()
print(a)</code></pre>
<blockquote>
<p>🖍️ <code>[1,2,3]</code></p>
</blockquote>
<ul>
<li><code>a = list(set([1, 2, 2, 3]))</code> 
<code>set</code> 중복 제거: <code>{1, 2, 3}</code>
<code>list</code> 변환 후 정렬 → <code>[1, 2, 3]</code></li>
</ul>
<h3 id="❌-bool-평가">❌ bool 평가</h3>
<pre><code class="language-python">print(bool([]), bool([0]), bool(0), bool(&quot;&quot;), bool(&quot;0&quot;))</code></pre>
<blockquote>
<p>🖍️ False, True, False, False, True</p>
</blockquote>
<ul>
<li><code>bool([])</code> → <code>False</code> (빈 리스트)</li>
<li><code>bool([0])</code> → <code>True</code> (리스트 안에 값이 있음)</li>
<li><code>bool(0)</code> → <code>False</code></li>
<li><code>bool(&quot;&quot;)</code> → <code>False</code> (빈 문자열)</li>
<li><code>bool(&quot;0&quot;)</code> → <code>True</code> (길이 있음)</li>
</ul>
<h3 id="❌-튜플-포함-리스트-변경">❌ 튜플 포함 리스트 변경</h3>
<pre><code class="language-python">x = ([1, 2], 3)
x[0].append(4)
print(x)</code></pre>
<blockquote>
<p>🖍️ `([1, 2, 4], 3)</p>
</blockquote>
<ul>
<li>튜플은 불변이지만, 내부 리스트는 가변
x는 <code>([1, 2, 4], 3)</code>이 됨</li>
</ul>
<h3 id="❌-문자열-인덱싱--슬라이싱">❌ 문자열 인덱싱 + 슬라이싱</h3>
<pre><code class="language-python">s = &quot;OpenAI&quot;
print(s[1:-1:2])</code></pre>
<blockquote>
<p>🖍️ pn
OpenAI
012345</p>
</blockquote>
<ul>
<li><code>s[1:-1]</code> → &#39;penA&#39;</li>
<li><code>[::2]</code> → &#39;pn&#39;</li>
</ul>
<h3 id="❌-리스트-연산과-할당">❌ 리스트 연산과 할당</h3>
<pre><code class="language-python">a = [1, 2, 3]
b = a
a += [4]
print(b)</code></pre>
<blockquote>
<p>🖍️ [1, 2, 3, 4]</p>
</blockquote>
<ul>
<li><code>b = [1, 2, 3]</code></li>
<li><code>a += [4]</code>는 리스트 제자리 수정
∴ <code>a = [1, 2, 3, 4]</code></li>
<li>a와 b는 같은 객체 → b도 변경됨</li>
</ul>
<h3 id="✅-is-연산자">✅ is 연산자</h3>
<pre><code class="language-python">x = 256
y = 256
print(x is y)</code></pre>
<blockquote>
<p>🖍️ True</p>
</blockquote>
<ul>
<li>파이썬은 <code>-5~256</code> 범위의 정수는 캐싱됨</li>
<li><code>x is y</code> → True</li>
</ul>
<h3 id="✅-문자열-곱하기와-슬라이싱">✅ 문자열 곱하기와 슬라이싱</h3>
<pre><code class="language-python">msg = &quot;ab&quot; * 3
print(msg[2:5])</code></pre>
<blockquote>
<p>🖍️ aba</p>
</blockquote>
<ul>
<li><code>msg = &quot;ababab&quot;</code>
ababab
012345</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: Python Lang.]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Python-Lang</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Python-Lang</guid>
            <pubDate>Mon, 07 Apr 2025 08:41:55 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="python-lang">Python Lang.</h2>
<h3 id="✅-문자열-슬라이싱의-step">✅ 문자열 슬라이싱의 step</h3>
<pre><code class="language-python">s = &quot;PythonRocks&quot;
print(s[::2])</code></pre>
<blockquote>
<p>🖍️ PhRk
<strong>해설</strong>: 인덱스 0, 2, 4, ...</p>
</blockquote>
<h3 id="✅-문자열-음수-인덱스-슬라이싱">✅ 문자열 음수 인덱스 슬라이싱</h3>
<pre><code class="language-python">text = &quot;abcdefghij&quot;
print(text[-4:-1])</code></pre>
<blockquote>
<p>🖍️ ghi
<strong>해설</strong>: <code>text[-4:-1]</code> == <code>text[6:9]</code> =&gt; &#39;ghi&#39;</p>
</blockquote>
<h3 id="✅-리스트-vs-튜플">✅ 리스트 vs 튜플</h3>
<pre><code class="language-python">a = [1, 2, 3]
b = (1, 2, 3)
a[0] = 100
# b[0] = 100

print(a[0], b[0]) # 튜플은 변경 불가</code></pre>
<blockquote>
<p>🖍️ 100, 1</p>
</blockquote>
<h3 id="❌-리스트-슬라이싱-복사">❌ 리스트 슬라이싱 복사</h3>
<pre><code class="language-python">x = [1, 2, 3, 4]
y = x[:]
x[0] = 99
print(y[0])</code></pre>
<blockquote>
<p>🖍️ 1</p>
</blockquote>
<ul>
<li><strong>리스트 슬라이싱(<code>[:]</code>)은 얕은 복사</strong>. 따라서 <strong><code>y</code>는 <code>x</code>와 분리된 새 리스트</strong>임</li>
<li><code>y</code>는 복사본으로 영향 없음 ∴ <code>y = [1, 2, 3, 4]</code></li>
<li><code>x = [99, 2, 3, 4]</code></li>
</ul>
<h3 id="❌-문자열-슬라이싱-reverse">❌ 문자열 슬라이싱: reverse</h3>
<pre><code class="language-python">word = &quot;DataScience&quot;
print(word[::-1][:4])</code></pre>
<blockquote>
<p>🖍️ ecne
<strong>해설</strong>:</p>
</blockquote>
<ul>
<li><code>word[::-1]</code> = &#39;ecneicSataD&#39;</li>
<li><code>word[:4]</code> = 앞 4글자 = &#39;ecne&#39;</li>
</ul>
<h3 id="❌-set">❌ set</h3>
<pre><code class="language-python">s = set(&quot;banana&quot;)
print(len(s))</code></pre>
<blockquote>
<p>🖍️ 3</p>
</blockquote>
<ul>
<li><strong><code>set</code>은 중복되는 값을 제거</strong>함</li>
<li><code>s = {&#39;b&#39;, &#39;a&#39;, &#39;n&#39;}</code></li>
</ul>
<h3 id="❌-딕셔너리-키-타입">❌ 딕셔너리 키 타입</h3>
<pre><code class="language-python">d = {}
d[1] = &quot;int&quot;
d[1.0] = &quot;float&quot;
print(d[1])</code></pre>
<blockquote>
<p>🖍️ float</p>
</blockquote>
<ul>
<li><strong>1과 1.0은 같은 키로 간주</strong>됨 (== 비교 결과가 True, hash도 같음)
따라서 float으로 덮어씀</li>
</ul>
<h3 id="✅-불변-튜플--가변-리스트">✅ 불변 튜플 + 가변 리스트</h3>
<pre><code class="language-python">x = (1, 2, [3, 4])
x[2].append(5)
print(x)</code></pre>
<blockquote>
<p>🖍️ <code>(1, 2, [3, 4, 5])</code></p>
</blockquote>
<ul>
<li><code>x[2]= [3,4]</code></li>
</ul>
<h3 id="❌-리스트-곱하기-복사-방식">❌ 리스트 곱하기 복사 방식</h3>
<pre><code class="language-python">a = [[0]] * 3
a[0][0] = 100
print(a)</code></pre>
<blockquote>
<p>🖍️ <code>[[100], [100], [100]]</code></p>
</blockquote>
<ul>
<li><code>[[0]] * 3</code>: 
<code>[[0]]</code> 리스트 객체를 3번 반복해서 참조한 것
즉, 내부의 3개의 리스트는 모두 같은 객체를 참조함 (id 값 동일)
<code>a = [[0], [0], [0]]</code></li>
<li><code>a[0][0] = 100</code>: 
이건 내부 리스트의 첫 번째 원소를 100으로 바꾸는 것
그런데 내부 리스트는 <strong>전부 같은 객체니까, 모든 리스트에 동시에 반영</strong>됨</li>
<li>❗ 왜 틀리기 쉬울까?
<code>*</code>는 새로운 객체를 만드는 게 아니라 <strong>기존 객체에 대한 참조를 반복</strong>해!
그래서 내부 리스트들이 독립적이지 않음</li>
</ul>
<h3 id="❌-문자열과-bool-int-변환">❌ 문자열과 bool, int 변환</h3>
<pre><code class="language-python">print(bool(&quot;False&quot;), int(&quot;False&quot; == &quot;false&quot;))</code></pre>
<blockquote>
<p>🖍️ True, 0
=&gt; </p>
</blockquote>
<ul>
<li><code>&quot;False&quot; == &quot;false&quot;</code> → <code>False</code> → <code>int(False)</code> = 0<h4 id="🔍-코드-흐름-분석">🔍 코드 흐름 분석</h4>
</li>
<li><code>bool(&quot;False&quot;)</code>:<ul>
<li>파이썬에서 빈 문자열(<code>&quot;&quot;</code>)은 <code>False</code>이고, 그 외 문자열은 모두 <code>True</code></li>
<li>결과는: <code>True</code> (비어 있지 않음)</li>
</ul>
</li>
<li><code>&quot;False&quot; == &quot;false&quot;</code>:<ul>
<li>대소문자 구분함 → &quot;False&quot;와 &quot;false&quot;는 다름</li>
<li>결과는: False</li>
</ul>
</li>
<li><code>int(False)</code>:<ul>
<li><code>False</code>는 파이썬에서 정수 <code>0</code>으로 변환됨</li>
<li><code>True</code>는 1, <code>False</code>는 0</li>
</ul>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: Java Lang.]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Java-Lang</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-Java-Lang</guid>
            <pubDate>Mon, 07 Apr 2025 07:09:21 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="java-lang">Java Lang.</h2>
<h3 id="✅-오버라이딩재정의과-업캐스팅">✅ 오버라이딩(재정의)과 업캐스팅</h3>
<pre><code class="language-java">class Parent {
    void show() {
        System.out.println(&quot;Parent&quot;);
    }
}

class Child extends Parent {
    void show() {
        System.out.println(&quot;Child&quot;);
    }
}

public class Test1 {
    public static void main(String[] args) {
        Parent obj = new Child();
        obj.show();
    }
}</code></pre>
<blockquote>
<p>🖍️ Child
<strong>해설</strong>: <code>Parent obj = new Child();</code> 상태에서 <code>obj.show()</code> 호출 → 오버라이딩된 <code>Child</code>의 <code>show()</code> 실행</p>
</blockquote>
<h3 id="✅-오버로딩서로-다른-인수">✅ 오버로딩(서로 다른 인수)</h3>
<pre><code class="language-java">class Overload {
    void print(int a) {
        System.out.println(&quot;int&quot;);
    }

    void print(double a) {
        System.out.println(&quot;double&quot;);
    }
}

public class Test2 {
    public static void main(String[] args) {
        Overload obj = new Overload();
        obj.print(10.5f);
    }
}</code></pre>
<blockquote>
<p>🖍️ double
<strong>해설</strong>: <code>10.5f</code>은 <code>float</code>이지만 정확히 일치하는 메서드가 없고, 자동 형변환으로 <code>double</code> 버전 호출됨</p>
</blockquote>
<h3 id="❌-메서드-하이딩-vs-오버라이딩">❌ 메서드 하이딩 vs 오버라이딩</h3>
<pre><code class="language-java">class A {
    static void hello() {
        System.out.println(&quot;Hello from A&quot;);
    }
}

class B extends A {
    static void hello() {
        System.out.println(&quot;Hello from B&quot;);
    }
}

public class Test3 {
    public static void main(String[] args) {
        A obj = new B();
        obj.hello();
    }
}</code></pre>
<blockquote>
<p>🖍️ Hello from A
<strong>해설</strong>: <code>static</code> 메서드는 인스턴스 타입이 아니라 참조 변수 타입 기준으로 호출됨 → <code>A obj = new B();</code> 이므로 <code>A.hello()</code> 호출
🙌 틀린 이유: <code>static</code>은 오버라이딩이 아닌 하이딩이며, 동적 바인딩이 적용되지 않음</p>
</blockquote>
<h3 id="✅-equals-vs-">✅ equals() vs ==</h3>
<pre><code class="language-java">public class Test4 {
    public static void main(String[] args) {
        String s1 = new String(&quot;hello&quot;);
        String s2 = new String(&quot;hello&quot;);

        System.out.println(s1 == s2);
        System.out.println(s1.equals(s2));
    }
}</code></pre>
<blockquote>
<p>🖍️ 
false
true
<strong>해설</strong>:</p>
</blockquote>
<ul>
<li><strong><code>==</code> → 주소</strong> 비교 (false), </li>
<li><strong><code>equals()</code> → 문자열 내용</strong> 비교 (true)</li>
</ul>
<h3 id="✅-오버라이딩-vs-멤버-변수-숨기기">✅ 오버라이딩 vs 멤버 변수 숨기기</h3>
<pre><code class="language-java">class Super {
    String name = &quot;Super&quot;;

    String getName() {
        return name;
    }
}

class Sub extends Super {
    String name = &quot;Sub&quot;;

    String getName() {
        return name;
    }
}

public class Test5 {
    public static void main(String[] args) {
        Super obj = new Sub();
        System.out.println(obj.name);
        System.out.println(obj.getName());
    }
}</code></pre>
<blockquote>
<p>🖍️ 
Super
Sub
<strong>해설</strong>: <code>obj.name</code>은 변수 숨기기 때문에 <code>Super</code> 출력, 
<code>getName()</code>은 오버라이딩된 <code>Sub</code> 쪽 실행</p>
</blockquote>
<h3 id="❌-오버로딩-해석-순서">❌ 오버로딩 해석 순서</h3>
<pre><code class="language-java">class Demo {
    void process(Object o) {
        System.out.println(&quot;Object&quot;);
    }

    void process(String s) {
        System.out.println(&quot;String&quot;);
    }
}

public class Test6 {
    public static void main(String[] args) {
        Demo demo = new Demo();
        demo.process(null);
    }
}</code></pre>
<blockquote>
<p>🖍️ String
<strong>해셜</strong>: 오버로딩은 가장 구체적인 타입 우선! 
<strong><code>null</code></strong>은 <code>Object</code>, <code>String</code> 모두에 해당하지만, <strong><code>String</code>이 더 구체적</strong>이므로 선택됨
❗ 틀린 이유: 오버로딩 해석 시 &quot;더 구체적인 타입 우선&quot; 이란 규칙을 놓침</p>
</blockquote>
<h3 id="✅-업캐스팅과-오버라이딩-메서드-호출">✅ 업캐스팅과 오버라이딩 메서드 호출</h3>
<pre><code class="language-java">class Animal {
    void speak() {
        System.out.println(&quot;Animal speaks&quot;);
    }
}

class Dog extends Animal {
    void speak() {
        System.out.println(&quot;Dog barks&quot;);
    }

    void wagTail() {
        System.out.println(&quot;Dog wags tail&quot;);
    }
}

public class Test7 {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.speak();
        // a.wagTail(); // 컴파일 에러
    }
}</code></pre>
<blockquote>
<p>🖍️ Dog barks
<strong>해설</strong>: <code>Animal a = new Dog();</code> → <code>a.speak()</code> 호출 시 오버라이딩된 <code>Dog</code>의 <code>speak()</code> 호출됨</p>
</blockquote>
<h3 id="✅-equals-오버라이딩">✅ equals 오버라이딩</h3>
<pre><code class="language-java">class Person {
    String name;

    Person(String name) {
        this.name = name;
    }

    public boolean equals(Object o) {
        if (o instanceof Person) {
            return this.name.equals(((Person) o).name);
        }
        return false;
    }
}

public class Test8 {
    public static void main(String[] args) {
        Person p1 = new Person(&quot;John&quot;);
        Person p2 = new Person(&quot;John&quot;);
        System.out.println(p1 == p2);      // Line A
        System.out.println(p1.equals(p2)); // Line B
    }
}</code></pre>
<blockquote>
<p>🖍️ 
false
true</p>
</blockquote>
<h4 id="🔎-line-a-p1--p2">🔎 Line A: p1 == p2</h4>
<ul>
<li><strong><code>==</code>는 객체의 참조값</strong>을 비교해.</li>
<li>p1과 p2는 <strong><code>new</code> 키워드로 서로 다른 객체로 생성</strong>됐기 때문에 참조가 다름.</li>
<li>따라서 결과는: ✅ false<h4 id="🔎-line-b-p1equalsp2">🔎 Line B: p1.equals(p2)</h4>
</li>
<li><code>equals()</code> 메서드를 오버라이딩 했기 때문에, 단순히 참조값이 아닌 <strong>내용 비교</strong>를 해.</li>
<li><code>this.name.equals(((Person) o).name)</code> → 즉 <code>p1.name.equals(p2.name)</code></li>
<li>둘 다 &quot;John&quot;이니까 결과는: ✅ true</li>
</ul>
<h3 id="✅-오버라이딩된-메서드와-생성자-순서">✅ 오버라이딩된 메서드와 생성자 순서</h3>
<pre><code class="language-java">class Base {
    Base() {
        print();
    }

    void print() {
        System.out.println(&quot;Base&quot;);
    }
}

class Derived extends Base {
    int num = 10;

    void print() {
        System.out.println(&quot;Derived: &quot; + num);
    }
}

public class Test9 {
    public static void main(String[] args) {
        new Derived();
    }
}</code></pre>
<blockquote>
<p>🖍️ Derived: 10
<strong>해설</strong>: <code>Derived</code> 생성자 호출 시, <code>Base</code> 생성자 내부에서 <code>print()</code> 호출
→ <code>Derived.print()</code> 오버라이딩됨 → <code>num</code>은 이미 초기화된 상태 → 10</p>
</blockquote>
<h3 id="❌-final-static-오버라이딩-혼합">❌ final, static, 오버라이딩 혼합</h3>
<pre><code class="language-java">class One {
    final void show() {
        System.out.println(&quot;One&quot;);
    }

    static void greet() {
        System.out.println(&quot;Static One&quot;);
    }
}

class Two extends One {
    // void show() {} // 컴파일 에러: final 메서드는 오버라이딩 불가

    static void greet() {
        System.out.println(&quot;Static Two&quot;);
    }
}

public class Test10 {
    public static void main(String[] args) {
        One o = new Two();
        o.show();
        o.greet();
    }
}</code></pre>
<blockquote>
<p>🖍️ 
One
Static One
<strong>해설</strong>:</p>
</blockquote>
<ul>
<li><code>show()</code>는 <code>final</code> → 오버라이딩 불가 → <code>One</code>의 메서드 실행됨 (O)</li>
<li><code>greet()</code>는 <code>static</code> → <strong>참조 타입 기준으로 호출</strong> → <code>One o = new Two();</code> → <code>One.greet()</code> 실행됨 → ❌ Static One이 맞는 출력</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: C Lang.]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-C-Lang-89qcobjd</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-C-Lang-89qcobjd</guid>
            <pubDate>Mon, 07 Apr 2025 05:30:30 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="c-lang">C Lang.</h2>
<h3 id="✅-포인터-배열을-통한-문자열-길이-계산">✅ 포인터 배열을 통한 문자열 길이 계산</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

int main() {
    char *arr[] = {&quot;apple&quot;, &quot;banana&quot;, &quot;kiwi&quot;};
    int total = 0;

    for (int i = 0; i &lt; 3; i++) {
        total += strlen(*(arr + i));
    }

    printf(&quot;%d\n&quot;, total);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 15
<code>strlen(apple)</code> = 5
<code>strlen(banana)</code> = 6
<code>strlen(kiwi)</code> = 4
total = 5 + 6 + 4 = 15</p>
</blockquote>
<h3 id="✅-구조체-배열에서-최대값-찾기">✅ 구조체 배열에서 최대값 찾기</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Info {
    char name[20];
    int score;
};

int main() {
    struct Info students[3] = {
        {&quot;Kim&quot;, 85},
        {&quot;Lee&quot;, 92},
        {&quot;Park&quot;, 87}
    };

    int max = students[0].score;
    char top[20];

    for (int i = 1; i &lt; 3; i++) {
        if (students[i].score &gt; max) {
            max = students[i].score;
            strcpy(top, students[i].name);
        }
    }

    printf(&quot;%s\n&quot;, top);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ Lee
<code>max</code> = 92 -&gt; <code>int</code> = 1
top = <code>students[1].name</code> = Lee</p>
</blockquote>
<h3 id="✅-배열-포인터로-2차원-배열-순회">✅ 배열 포인터로 2차원 배열 순회</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
    int (*p)[3] = arr;
    int sum = 0;

    for (int i = 0; i &lt; 2; i++) {
        for (int j = 0; j &lt; 3; j++) {
            sum += *(*(p + i) + j);
        }
    }

    printf(&quot;%d\n&quot;, sum);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 21
<code>int = 0</code>
<code>sum</code> = 1 + 2 + 3
<code>int = 1</code>
<code>sum</code> = (1 + 2 + 3) + 4 + 5 + 6</p>
</blockquote>
<h3 id="✅-구조체--포인터-연산--조건">✅ 구조체 + 포인터 연산 + 조건</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Point {
    int x, y;
};

int main() {
    struct Point arr[] = {{1, 2}, {3, 4}, {5, 6}};
    struct Point *p = arr;
    int result = 0;

    for (int i = 0; i &lt; 3; i++) {
        if ((p + i)-&gt;x % 2 == 1) {
            result += (p + i)-&gt;y;
        }
    }

    printf(&quot;%d\n&quot;, result);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 12</p>
</blockquote>
<ul>
<li><code>(p + 0)-&gt;x</code> = 1, <code>(p + 1)-&gt;x</code> = 3, <code>(p + 2)-&gt;x</code> = 5</li>
<li><code>if ((p + i)-&gt;x % 2 == 1)</code>를 만족하는 <code>i</code>는 0, 3, 5</li>
<li><code>result</code> = 2 + 4 + 6 = 12</li>
</ul>
<h3 id="✅-증감연산자와-포인터를-함께-사용">✅ 증감연산자와 포인터를 함께 사용</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    int arr[] = {10, 20, 30};
    int *p = arr;
    int a = *p++;
    int b = *p;
    printf(&quot;%d %d\n&quot;, a, b);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 10 10 </p>
</blockquote>
<ul>
<li><code>p++</code>는 후위 연산자 이므로 <code>a</code>에는 값 10이 저장 됌.</li>
<li><code>b = *p</code> 이므로 <code>b</code>도 10이 저장 됌.</li>
</ul>
<h3 id="✅-구조체-포인터-배열--조건">✅ 구조체 포인터 배열 + 조건</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

struct Book {
    char title[20];
    int pages;
};

int main() {
    struct Book b1 = {&quot;C Lang&quot;, 350};
    struct Book b2 = {&quot;Data&quot;, 200};
    struct Book *books[] = {&amp;b1, &amp;b2};
    int total = 0;

    for (int i = 0; i &lt; 2; i++) {
        if (books[i]-&gt;pages &gt; 300)
            total += strlen(books[i]-&gt;title);
    }

    printf(&quot;%d\n&quot;, total);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 6</p>
</blockquote>
<ul>
<li><code>int = 0</code>
<code>books[0]-&gt;pages &gt; 300</code> = <code>350 &gt; 300</code> -&gt; true
<code>total += strlen(books[0]-&gt;title);</code> -&gt; <code>strlen(&quot;C Lang&quot;)</code>
∴ total = 6
<code>int = 1</code>
<code>books[1]-&gt;pages &gt; 300</code> = <code>200 &gt; 300</code> -&gt; false</li>
</ul>
<h3 id="✅-배열-포인터로-조건-탐색">✅ 배열 포인터로 조건 탐색</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

int main() {
    char strs[2][10] = {&quot;cat&quot;, &quot;tiger&quot;};
    char (*p)[10] = strs;
    int count = 0;

    for (int i = 0; i &lt; 2; i++) {
        if (strchr(p[i], &#39;t&#39;) != NULL) {
            count++;
        }
    }

    printf(&quot;%d\n&quot;, count);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 2</p>
</blockquote>
<ul>
<li><code>strchr()</code> 함수는 string에서 문자의 첫 번째 표시를 찾으며, Null로 끝나는 string에서 작동.</li>
<li><code>strchr(p[0], &#39;t&#39;)</code> : &quot;cat&quot;에서 &quot;t&quot;가 몇 번째에 있는지를 찾음 -&gt; 2</li>
<li><code>strchr(p[1], &#39;t&#39;)</code> : &quot;tiger&quot;에서 &quot;t&quot;가 몇 번째에 있는지를 찾음 -&gt; 0</li>
</ul>
<h3 id="✅-구조체--포인터--반복문--누적">✅ 구조체 + 포인터 + 반복문 + 누적</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Sensor {
    float temp;
};

int main() {
    struct Sensor sensors[4] = {{23.5}, {25.1}, {22.8}, {24.9}};
    struct Sensor *p = sensors;
    float sum = 0;

    for (int i = 0; i &lt; 4; i++) {
        sum += (p + i)-&gt;temp;
    }

    printf(&quot;%.1f\n&quot;, sum);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 96.3
sum = 23.5 + 25.1 + 22.8 + 24.9 = 96.3</p>
</blockquote>
<h3 id="✅-문자열-함수-활용-조건문">✅ 문자열 함수 활용 조건문</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

int main() {
    char *list[] = {&quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;avocado&quot;};
    int count = 0;

    for (int i = 0; i &lt; 4; i++) {
        if (strncmp(list[i], &quot;ap&quot;, 2) == 0)
            count++;
    }

    printf(&quot;%d\n&quot;, count);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 2</p>
</blockquote>
<ul>
<li><code>strncmp(list[i], &quot;ap&quot;, 2)</code> → 문자열 <code>list[i]</code>의 앞 2글자가 &quot;ap&quot;와 같은지 확인하는 조건
∴ &quot;apple&quot;, &quot;apricot&quot;</li>
</ul>
<h3 id="✅-다차원-배열과-포인터">✅ 다차원 배열과 포인터</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    int arr[2][2] = {{1, 2}, {3, 4}};
    int *p = &amp;arr[0][0];

    *(p + 2) += 5;
    printf(&quot;%d\n&quot;, arr[1][0]);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 8</p>
</blockquote>
<ul>
<li><code>*(p + 2) += 5</code> → <code>arr[1][0] = 3 + 5</code> = 8</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Leveraging Programming Languages: C Lang.]]></title>
            <link>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-C-Lang</link>
            <guid>https://velog.io/@m_ngyeong/Leveraging-Programming-Languages-C-Lang</guid>
            <pubDate>Mon, 07 Apr 2025 02:42:03 GMT</pubDate>
            <description><![CDATA[<h1 id="10-leveraging-programming-languages">10. Leveraging Programming Languages</h1>
<hr>
<h2 id="c-lang">C Lang.</h2>
<h3 id="✅-포인터와-배열">✅ 포인터와 배열</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    int arr[5] = {10, 20, 30, 40, 50};
    int *ptr = arr;
    int sum = 0;

    for (int i = 0; i &lt; 5; i++) {
        sum += *(ptr + i);  // 포인터로 배열 접근
    }

    printf(&quot;평균: %.2f\n&quot;, sum / 5.0);
    return 0;
}</code></pre>
<ul>
<li>sum = 10 + 20 + 30 + 40 + 50 = 150</li>
<li>sum / 5.0 = 30</li>
<li>%.2f = 30.00<blockquote>
<p>🖍️ 평균: 30.00</p>
</blockquote>
</li>
</ul>
<h3 id="✅-switch-case">✅ switch-case</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    double a = 12.0;
    double b = 4.0;
    char op = &#39;*&#39;;  // 연산자: +, -, *, /

    switch (op) {
        case &#39;+&#39;:
            printf(&quot;%.2f + %.2f = %.2f\n&quot;, a, b, a + b);
            break;

        case &#39;-&#39;:
            printf(&quot;%.2f - %.2f = %.2f\n&quot;, a, b, a - b);

        case &#39;*&#39;:
            printf(&quot;%.2f * %.2f = %.2f\n&quot;, a, b, a * b);

        case &#39;/&#39;:
            if (b != 0)
                printf(&quot;%.2f / %.2f = %.2f\n&quot;, a, b, a / b);
            else
                printf(&quot;0으로 나눌 수 없습니다!\n&quot;);
            break;

        default:
            printf(&quot;잘못된 연산자입니다.\n&quot;);
    }

    return 0;
}</code></pre>
<ul>
<li>break 제거 (fall-through 발생)</li>
<li>switch-case는 위에서부터 차례대로 읽어 내려오며 해당하는 구문 실행 
<code>op=*</code> 이기 때문에 아래 구문 실행<pre><code class="language-c">case &#39;*&#39;:
printf(&quot;%.2f * %.2f = %.2f\n&quot;, a, b, a * b);</code></pre>
</li>
<li><code>case &#39;*&#39;</code> 구문에는 <code>break</code>가 없기 때문에 <code>case &#39;/&#39;</code>도 실행</li>
</ul>
<blockquote>
<p>🖍️
12.00 * 4.00 = 48.00
12.00 / 4.00 = 3.00</p>
</blockquote>
<h3 id="✅-조건문---짝홀">✅ 조건문 - 짝/홀</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    int arr[] = {3, 8, 12, 7, 6, 10, 1};
    int even[7]; // C에서는 크기 없는 배열은 선언 안됌
    int count = 0;

    int length = sizeof(arr) / sizeof(arr[0]);

    for(int i=0; i&lt;length; i++){
        if(arr[i]%2 == 0){        // if(arr[i] % 2 != 0): 홀수만 출력
            even[count] = arr[i]; // count를 인덱스로 사용
            count ++;
        }
    } // 짝수 목록: 8 12 6 10 

    // 버블 정렬로 오름차순 정렬
    for (int i = 0; i &lt; count - 1; i++) {
        for (int j = 0; j &lt; count - i - 1; j++) {
            if (even[j] &gt; even[j + 1]) {
                int temp = even[j];
                even[j] = even[j + 1];
                even[j + 1] = temp;
            }
        }
    } 

    printf(&quot;%d\n&quot;, count);
    printf(&quot;짝수 목록: &quot;);
    for (int i = 0; i &lt; count; i++) {
        printf(&quot;%d &quot;, even[i]);
    }
    printf(&quot;\n&quot;);

    return 0;
}</code></pre>
<ul>
<li>if(arr[i]%2 == 0): 짝수만</li>
<li>if(arr[i] % 2 != 0): 홀수만</li>
</ul>
<blockquote>
<p>🖍️
4
짝수 목록: 6 8 10 12 </p>
</blockquote>
<h3 id="✅-문자-배열에서-대문자만-출력">✅ 문자 배열에서 대문자만 출력</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    char str[] = &quot;HeLLoWorLD&quot;;
    int length = sizeof(str)/ sizeof(str[0]);

    for(int i=0; i&lt;length; i++){
        char ch = str[i];
        if (ch &gt;= &#39;A&#39; &amp;&amp; ch &lt;= &#39;Z&#39;){
            printf(&quot;%c&quot;, ch);
        }
    }
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ HLLWLD</p>
</blockquote>
<hr>
<h3 id="✅-구조체-아이템-접근">✅ 구조체 아이템 접근</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Product {
    char name[10];
    int price;
};

int main() {
    struct Product items[2] = {
        {&quot;Pen&quot;, 500},
        {&quot;Book&quot;, 1200}
    };
    int sum = 0;
    for (int i = 0; i &lt; 2; i++) {
        sum += items[i].price;
    }
    printf(&quot;%d\n&quot;, sum);
    return 0;
}</code></pre>
<ul>
<li><code>sum += items[i].price;</code> 구조체 아이템 접근</li>
</ul>
<blockquote>
<p>🖍️ 1700</p>
</blockquote>
<h3 id="✅-구조체-포인터">✅ 구조체 포인터</h3>
<pre><code>#include &lt;stdio.h&gt;

struct Point {
    int x;
    int y;
};

int main() {
    struct Point p = {3, 4};
    struct Point *ptr = &amp;p;

    printf(&quot;%d\n&quot;, ptr-&gt;x + ptr-&gt;y);
    return 0;
}</code></pre><blockquote>
<p>🖍️ 7</p>
</blockquote>
<h3 id="✅-구조체-초기화">✅ 구조체 초기화</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Car {
    char name[10];
    int year;
    int price;
};

int main() {
    struct Car c = {&quot;Sonata&quot;, 2020};
    printf(&quot;%d\n&quot;, c.price);
    return 0;
}</code></pre>
<ul>
<li>구조체 전역/로컬 선언 시 초기값은 0, 특히 main()에서 선언된 정적 지역 변수는 보장됨</li>
</ul>
<blockquote>
<p>🖍️ 0</p>
</blockquote>
<h3 id="✅-구조체-포인터를-함수로-전달">✅ 구조체 포인터를 함수로 전달</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Data {
    int x;
    int y;
};

void update(struct Data *d) {
    d-&gt;x += 5;
    d-&gt;y *= 2;
}

int main() {
    struct Data d = {2, 3};
    update(&amp;d);
    printf(&quot;%d %d\n&quot;, d.x, d.y);
    return 0;
}</code></pre>
<blockquote>
<p>🖍️ 7 6</p>
</blockquote>
<h3 id="✅-구조체-배열과-조건-판단">✅ 구조체 배열과 조건 판단</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Score {
    char name[10];
    int score;
};

int main() {
    struct Score list[3] = {
        {&quot;Kim&quot;, 85},
        {&quot;Lee&quot;, 92},
        {&quot;Park&quot;, 78}
    };
    int count = 0;

    for (int i = 0; i &lt; 3; i++) {
        if (list[i].score &gt;= 80) {
            count++;
        }
    }

    printf(&quot;%d\n&quot;, count);
    return 0;
}</code></pre>
<blockquote>
<p> 🖍️ 2</p>
</blockquote>
<h3 id="✅-구조체-리턴-함수">✅ 구조체 리턴 함수</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Point {
    int x, y;
};

struct Point move(struct Point p) {
    p.x += 10;
    p.y += 10;
    return p;
}

int main() {
    struct Point p = {1, 2};
    struct Point result = move(p);
    printf(&quot;%d %d\n&quot;, result.x, result.y);
    return 0;
}</code></pre>
<blockquote>
<p> 🖍️ 11 12</p>
</blockquote>
<h3 id="✅-중첩-구조체">✅ 중첩 구조체</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Date {
    int year, month, day;
};

struct Person {
    char name[20];
    struct Date birth;
};

int main() {
    struct Person p = {&quot;Jin&quot;, {1999, 12, 5}};
    printf(&quot;%d\n&quot;, p.birth.year);
    return 0;
}</code></pre>
<blockquote>
<p> 🖍️ 1999</p>
</blockquote>
<h3 id="✅-구조체-포인터-배열">✅ 구조체 포인터 배열</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

struct Info {
    char name[10];
    int level;
};

int main() {
    struct Info a = {&quot;Alice&quot;, 2};
    struct Info b = {&quot;Bob&quot;, 3};
    struct Info* arr[2] = {&amp;a, &amp;b};

    printf(&quot;%s %d\n&quot;, arr[1]-&gt;name, arr[0]-&gt;level);
    return 0;
}</code></pre>
<blockquote>
<p> 🖍️ Bob 2</p>
</blockquote>
]]></description>
        </item>
    </channel>
</rss>