| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 596 人关注过本帖
标题:求教getchar的详细用法
取消只看楼主 加入收藏
huaheshang
Rank: 2
来 自:日照
等 级:论坛游民
帖 子:91
专家分:37
注 册:2010-12-7
结帖率:79.31%
收藏
已结贴  问题点数:8 回复次数:0 
求教getchar的详细用法
#include<stdio.h>
main()
{
  char sex,sports,diet;
  float myheight,maheight,faheight;
  printf("are you a boy(b) or a girl(g)?");
  scanf("%c",&sex);
  printf("please input your mather'height--(cm):");
  scanf("%f",&maheight);
  printf("please input your father'height--(cm):");
  scanf("%f",&faheight);

  printf("do you like sports(y/n)?");
  getchar();
  scanf("%c",&sports);
  printf("do you have a good habit of diet(y/n)?");
   getchar();
  scanf("%c",&diet);
  if(sex=='b')
   myheight=(maheight+faheight)*0.54;
   else
   myheight=(maheight+faheight)*0.5;
  if(sports=='y')
   myheight=myheight*1.102;
   else
   myheight=(faheight*0.923+maheight)*0.5;
   if(diet=='y')
   myheight=myheight*1.1015;
  printf("your future height will be  %f (cm)\n",myheight);
  getch();
   
}
程序中的getchar为什么不可省略,getchar的详细用法及注意事项,请详细讲一下
谢谢
搜索更多相关主题的帖子: father girl include please sports 
2013-04-10 12:53
快速回复:求教getchar的详细用法
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.010963 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved