以4.8%的格式读取一个数值,并将其转换为小数存入到浮点型变量percent中,输出percent的值。
提示:1)在输入流中剔除%。
2)输出时根据数值的大小,自动选取小数或科学计数法中输出宽度较小的一种,且不输出无意义的0。
Sample Input:
65%
Sample Output:
0.65
Sample Input:
0.00045%
Sample Output:
4.5e-006
c++语言
以4.8%的格式读取一个数值,并将其转换为小数存入到浮点型变量percent中,不带%输出percent的值,代码如下,仅使用scanf和printf即可:
#include <stdio.h>
int main()
{
float percent;char text[10];
scanf("%f%%",&percent);percent=percent/100;
printf("%.03g\n",percent);
return 0;}