每日一题 No.33 字符串转数字函数的学习

来源:互联网 发布:淘宝售后率是什么意思 编辑:程序博客网 时间:2024/05/20 15:57

本题要求:

今天学习一下atoi,atol,atof,atoll这四个函数

输入格式:

输出格式:

输入样例:

输出样例:

解题思路 :

atoi是将字符串转为int类型
atol是将字符串转为long类型
atoll是将字符串转为long long 类型
atof是将字符串转为float类型

代码 :

#include <iostream>#include <cstdlib> using namespace std;int main(void) {    cout << atoi("   +1111d ") << endl;    cout << atof("   +1111.1..1.1d ") << endl;    cout << atol("   +111112311.223d ") << endl;    cout << atoll("   +1111123123213.123d ") << endl;    return 0;}
0 0
原创粉丝点击