#include<iostream> #include<string> using namespace std; int ai(const char *p){ bool negflag = false; int rs = 0; if(*p=='+'||*p=='-'){ negflag=(*p=='-'); p++; } while(isdigit(*p)){ rs=rs*10+(*p-'0'); p++; } if(negflag) rs=0-rs; return rs; } void main(){ const char a[] ="123"; int k; k=ai(a); cout<<k; system("pause"); }
时间: 2024-10-24 13:29:59