/************************************************************************/
/* 题目:输入一个表示整数的字符串,把该字符串转换成整数并输出。
例如输入字符串"345",则输出整数345。 其实就是写一个atoi函数
未考虑整数溢出情况 */
/************************************************************************/
#include <iostream>
#include <string>
using namespace std;
int my_atoi(char *p)
{
bool neg_flg=false;
if(!p)
{
return -1;
}
if ((*p)=='+'||(*p)=='-')
{
neg_flg=((*p)=='-');
p++;
}
int result=0;
while (isdigit(*p))
{
result=result*10+(*p-'0');
p++;
}
return neg_flg? -result:result;
}
int main()
{
char p[100];
gets(p);
cout<<my_atoi(p);
return 0;
}