<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Stdlib.h on Sobamemil</title>
    <link>https://blog.sobamemil.com/en/tags/stdlib.h/</link>
    <description>Recent content in Stdlib.h on Sobamemil</description>
    <image>
      <title>Sobamemil</title>
      <url>https://blog.sobamemil.com/images/og-image.png</url>
      <link>https://blog.sobamemil.com/images/og-image.png</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 28 Feb 2020 20:00:03 +0900</lastBuildDate>
    <atom:link href="https://blog.sobamemil.com/en/tags/stdlib.h/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>C&#43;&#43; Programming Ch.2 Exercise 15 Solution</title>
      <link>https://blog.sobamemil.com/en/posts/041-%EB%AA%85%ED%92%88-c-programming-%EC%8B%A4%EC%8A%B5-%EB%AC%B8%EC%A0%9C-2%EC%9E%A5-15%EB%B2%88/</link>
      <pubDate>Fri, 28 Feb 2020 20:00:03 +0900</pubDate>
      <guid>https://blog.sobamemil.com/en/posts/041-%EB%AA%85%ED%92%88-c-programming-%EC%8B%A4%EC%8A%B5-%EB%AC%B8%EC%A0%9C-2%EC%9E%A5-15%EB%B2%88/</guid>
      <description>&lt;p&gt;&lt;b&gt;Problem:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;덧셈(+), 뺄셈(-), 곱셈(*), 나눗셈(/), 나머지(%)의 정수 5척 연산을 할 수 있는 프로그램을 작성하라. 식은 다음과 같은 형식으로 입력된다. 정수와 연산자는 하나의 빈칸으로 분리된다.&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://img.sobamemil.com/posts/41/img_1.png&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Objective &amp;amp; Hints:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;공백을 포함하는 문자열 읽기, C++ 프로그램 종합 응용&lt;/p&gt;
&lt;p&gt;한 줄을 문자열로 읽고, 공백 문자를 찾아 연산자와 두 개의 피연산자를 구분한 후, 계산하면 됩니다.&lt;/p&gt;
&lt;p&gt;문자열을 정수로 바꿀 때 atoi() 함수를 이용하면 됩니다.&lt;/p&gt;
&lt;p&gt;예를 들면 atoi(&amp;quot;34&amp;quot;) = 34 입니다.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Execution Result:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://img.sobamemil.com/posts/41/img_2.png&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36 37&lt;/td&gt;
          &lt;td&gt;#include&lt;iostream&gt;  #include&lt;cstring&gt; #include&lt;cstdlib&gt;  using namespace std;    int main(){    char sic[100];  char *symbol;    int front,rear;    while(true){  cout &amp;lt;&amp;lt; &amp;quot;? &amp;quot;;  cin.getline(sic,100);  front = atoi(strtok(sic, &amp;quot; &amp;quot;));  symbol = strtok(NULL, &amp;quot; &amp;quot;);  rear = atoi(strtok(NULL, &amp;quot; &amp;quot;));    if(*symbol == &#39;+&#39;){  cout &amp;lt;&amp;lt; front &amp;lt;&amp;lt; &amp;quot; + &amp;quot; &amp;lt;&amp;lt; rear &amp;lt;&amp;lt; &amp;quot; = &amp;quot; &amp;lt;&amp;lt; front+rear &amp;lt;&amp;lt; endl;  }  else if(*symbol == &#39;-&#39;){  cout &amp;lt;&amp;lt; front &amp;lt;&amp;lt; &amp;quot; - &amp;quot; &amp;lt;&amp;lt; rear &amp;lt;&amp;lt; &amp;quot; = &amp;quot; &amp;lt;&amp;lt; front-rear &amp;lt;&amp;lt; endl;  }  else if(*symbol == &#39;*&#39;){  cout &amp;lt;&amp;lt; front &amp;lt;&amp;lt; &amp;quot; * &amp;quot; &amp;lt;&amp;lt; rear &amp;lt;&amp;lt; &amp;quot; = &amp;quot; &amp;lt;&amp;lt; front*rear &amp;lt;&amp;lt; endl;  }  else if(*symbol == &#39;/&#39;){  cout &amp;lt;&amp;lt; front &amp;lt;&amp;lt; &amp;quot; / &amp;quot; &amp;lt;&amp;lt; rear &amp;lt;&amp;lt; &amp;quot; = &amp;quot; &amp;lt;&amp;lt; front/rear &amp;lt;&amp;lt; endl;  }  else if(*symbol == &#39;%&#39;){  cout &amp;lt;&amp;lt; front &amp;lt;&amp;lt; &amp;quot; % &amp;quot; &amp;lt;&amp;lt; rear &amp;lt;&amp;lt; &amp;quot; = &amp;quot; &amp;lt;&amp;lt; front%rear &amp;lt;&amp;lt; endl;  }  }  return 0;  }&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;b&gt;Explanation:&lt;/b&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
