#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include
int Myatoi(const char* str)
{
if (str == NULL || strlen(str) == 0)
return 0;
while (*str == ’ ’ || *str == ‘+’&&*str!=’\0’)
{
str++;
}
int flag = 1;
if (*str == ‘-’)
{
str++;
flag = 0;
}
int ret = 0;
while (*str && isdigit(*str))
{
ret = ret * 10 + *str - ‘0’;
str++;
}
if (flag == 1)
return ret;
else
return -ret;
}
int main()
{
char str[100]=" “;
scanf(”%s",str);
int ret = Myatoi(str);
printf("%d\n", ret);
system(“pause”);
return 0;
}
myatoi
最新推荐文章于 2024-03-05 12:38:02 发布
2679

被折叠的 条评论
为什么被折叠?



