r4t5y6u7 @ 2023-11-25 10:32:32
#include<iostream>
using namespace std;
int main()
{
int g,s,b,q,n;
cin>>n;
n*=10;
g=n%1000;
s=n%100/10;
b=n/100%10;
q=n/1000;
cout<<g<<"."<<s<<b<<q;
return 0;
}
by yzm0325 @ 2023-11-25 10:35:02
@fengyb1026 《浮点数用 int》
by danlao @ 2023-11-25 10:36:59
@fengyb1026
int g,s,b,q,n;//浮点数用int?
by r4t5y6u7 @ 2023-11-25 10:56:49
这样也不行啊
#include<iostream>
using namespace std;
int main()
{
int g,s,b,q;
float n;
cin>>n;
n*=10;
g=n%1000;
s=n%100/10;
b=n%10/100;
q=n/1000;
cout<<g<<"."<<s<<b<<q;
return 0;
}
by skyblue3 @ 2023-11-25 11:04:09
不能用float模int吧
by cheng_de @ 2024-02-04 09:32:01
@r4t5y6u7 你咋不用double啊<编程小白不用看>。
by r4t5y6u7 @ 2024-03-01 20:52:55
#include<bits/stdc++.h>
using namespace std;
int main()
{
int g,s,b,q,sum;
double n;
cin>>n;
sum=10*n;
g=sum%1000;
s=sum%100/10;
b=sum%10/100;
q=sum/1000;
cout<<q*0.001+b*0.01+s*0.1+g;
return 0;
}
还是不行。。。