坚持可持续 2017-09-24 13:16 采纳率: 0%
浏览 2129
已采纳

基础C++ 关于scanf取%.2f的问题

 #include<stdio.h>

int main(void)
{   
    float c;
    int t,a=0,i;
     int r=5;

   **_  scanf("%f ",&c);        _**         //当我把%f换成%.2f则无输出结果,为什么
    scanf("%d",&t);
    i=t/5;

     for(a=1;a<=i;a++)
    {
     printf("time : %d, calorie : %.2f\n",a*r,a*r*c);
        }

    return 0;}

图片说明d/201709/24/1506258965_275502.png)

  • 写回答

2条回答 默认 最新

  • shen_wei 2017-09-30 08:24
    关注
     %[*] [width] [{h | l | ll | I64 | L}]type
    
    The format argument specifies the interpretation of the input and can contain one or more of the following: 
    
    White-space characters: blank (' '); tab ('\t'); or newline ('\n'). A white-space character causes scanf to read, but not store, all consecutive white-space characters in the input up to the next non–white-space character. One white-space character in the format matches any number (including 0) and combination of white-space characters in the input.
    
    Non–white-space characters, except for the percent sign (%). A non–white-space character causes scanf to read, but not store, a matching non–white-space character. If the next character in the input stream does not match, scanf terminates.
    
    Format specifications, introduced by the percent sign (%). A format specification causes scanf to read and convert characters in the input into values of a specified type. The value is assigned to an argument in the argument list.
    
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?