You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
442 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include<bits/stdc++.h>
using namespace std;
/**
* 功能:将指定的数字转为字符串
* 作者:黄海
* 时间2019-10-31
* @param a
* @return
*/
string convertNumToStr(double a) {
string res;
//定义流ss
stringstream ss;
ss << a;
//将数字a转化成流ss
ss >> res;
//将流ss转化成字符串
return res;
}
int main() {
double a = 123.32;
string a_str=convertNumToStr(a);
cout << a_str<< endl;
return 0;
}