还有一种办法,就是用stringstream函数将每一次的数全都转化成char一维数组样式的字符串,然后逐位扫一遍即可。
(记得判断字符时将规定数字+48)
//Stand up for the faith! #include#define LL long long #define FRO freopen #define FCO fclose #define US unsigned #define RI register #define CN const #define MAXN 20001 #define INF 0x3f3f3f3f using namespace std; inline LL read() { LL s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')w=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { s=s*10+ch-'0'; ch=getchar(); } return s*w; } char c[1313]; LL n,m,ans=0; int main(void) { n=read(); m=read(); m+=48; for(int i=1;i<=n;i++) { stringstream ss; ss< >c; for(int j=0;j