/*string 获取double*/
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<sstream>
using namespace std;
int main(){
string str;
cin>>str;
double n;
//法一:
/*sscanf(str.c_str(),"%lf",&n);
printf("%lf\n",n);*/
/*
法二:
stringstream ss;//字符串流
n=atof(str.c_str());
printf("%lf\n",n);
*/
/*法三
stringstream ss;
ss<<str;
char c;
ss>>c;
ss.unget();
ss>>n;
printf("%lf\n",n);
*/
}
string 中截取int或double
最新推荐文章于 2022-09-26 00:09:27 发布