字符串输入:
#include
using namespace std;
int main()
{
char s[22];
int i=0;
cin>>s;
while(1)
{
if(s[i++]=='.')break;
}
while(s[i])
cout<cout<return 0;
}
double型输入:
#include
using namespace std;
int main()
{
double in;
int n;
cin>>in;
n=(int)((in-(int)in)*1000000);//小数部分
while(1)
{
if(n%10!=0)break;
n/=10; //去掉后面的0
}
cout<return 0;
}
float a=3.1313f;
printf("%f",a-(int)a);
是输入字符串还是双精度 ?