/*题目4:(简答题:10.0分)
实现函数将点分十进制表示的字符串转换为 unsigned int 整型数值
unsigned int my_ResDotDec(const char *strip);
参数说明:strip 点分十进制表示的字符串;
示例: strip =“128.11.3.31” ; 返回值: 2148205343;
strip =“128.399.2.12” ; 返回值为 UINT_MAX
#include <iostream>
#include <ctype.h>
#include <limits.h>
#include <stack>
using namespace std;
//处理单个atoi
int my_atoi_single(const char p)
{
return p - '0';
}
//atoi的子函数,将进制,字符,符号传递进来
unsigned int my_atoi_Son(const char *p,int system)
{
stack<char> sta;
unsigned int sum = 0;
unsigned int tmp = 0;
while(isdigit(*p))
{
sta.push(*p);
p++;
}
int n = sta.size();
for(int i = 0; i < n;++i)
{
tmp = my_atoi_single(sta.top());
sta.pop();
for(int j = 0;j < i;++j)
{
tmp = tmp * system;
}
sum += tmp;
}
return sum;