输入一个浮点数,如果该浮点数没有小数部分(也就是说该数字是整数),则输出该数字的三倍,否则输出比该数字小的最大整数。
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
float f;
while (1) {
scanf("%f",&f);
int out = f;
if(f > (float)out)
;
else
{
out *= 3;
}
printf("Output: %d\n",out);
}
return 0;
}
int n;
fgets(buff,1024,stdin);//buff为你输入的数字
if(NULL==strchr(buff,'.'))
{
n=strtol(buff,NULL,10);
n=n * 3;
}
else
{
n=strtol(buff,NULL,10);
}