#include<stdio.h> #define M 10 int my_atoi(char s[]) { int num=0; int i=0; while((s[i]=getchar())!=‘\n‘) { if(s[i]>=‘0‘&&s[i]<=‘9‘) num=(num*10)+(s[i]-‘0‘); i++; } if(s[0]==‘-‘) num=-num; return num; } int main() { char arr[M]={0}; printf("%d",my_atoi(arr)); return 0; }
时间: 2024-10-28 02:07:44