身高预测

太难了啊 发表于2020年11月13日
<p>#include &lt;stdio.h&gt;</p><p>int main(int argc, char *argv[])</p><p>{</p><p> double fatherheight;</p><p> double motherheight;</p><p> double boyheight;</p><p> double girlheight;</p><p> char sex;</p><p> printf(&quot;请输入父亲身高和母亲身高,输入格式为:?,?\n&quot;);</p><p> scanf(&quot;%lf%lf&quot;,&amp;fatherheight,&amp;motherheight);</p><p> getwchar();</p><p> printf(&quot;输入孩子性别m为男孩f为女孩\n&quot;);</p><p> scanf(&quot;%c&quot;,&amp;sex);</p><p> //printf(&quot;%d&quot;,sex);</p><p> if(sex=='m'){</p><p> boyheight = (fatherheight + motherheight)*1.08/2;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;男孩身高:%.2f\n&quot;,boyheight);</p><p> }</p><p> if(sex=='f'){</p><p> girlheight = (fatherheight + 0.923*motherheight)/2;</p><p> &nbsp; &nbsp; printf(&quot;女孩身高:%.2f\n&quot;,girlheight);</p><p> }&nbsp;</p><p> return 0;</p><p>}</p><p><br ></p>
1 回复

    1楼

  • 太难了啊 发表于2020年11月13日
    0 | 0 | 举报
    <p>#include &lt;stdio.h&gt;</p><p>int main(int argc, char *argv[])</p><p>{</p><p> double fatherheight;</p><p> double motherheight;</p><p> double boyheight;</p><p> double girlheight;</p><p> char sex;</p><p> printf(&quot;请输入父亲身高和母亲身高,输入格式为:?,?\n&quot;);</p><p> scanf(&quot;%lf%lf&quot;,&amp;fatherheight,&amp;motherheight);</p><p> getwchar();</p><p> printf(&quot;输入孩子性别m为男孩f为女孩\n&quot;);</p><p> scanf(&quot;%c&quot;,&amp;sex);</p><p> if(sex=='m'||sex=='M'){</p><p> boyheight = (fatherheight + motherheight)*1.08/2;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;男孩身高:%.2f\n&quot;,boyheight);</p><p> }</p><p> if(sex=='f'||sex=='F'){</p><p> girlheight = (fatherheight + 0.923*motherheight)/2;</p><p> &nbsp; &nbsp; printf(&quot;女孩身高:%.2f\n&quot;,girlheight);</p><p> }&nbsp;</p><p> if(sex!='m'&amp;&amp;sex!='M'&amp;&amp;sex!='f'&amp;&amp;sex!='F'){</p><p> printf(&quot;输入错误,请重新输入\n&quot;);</p><p> }</p><p> return 0;</p><p>}</p><p><br ></p>
    太难了啊 发表于2020年11月13日
    添加评论