题解 | #游游的整数切割#
游游的整数切割
https://www.nowcoder.com/practice/c01b07fe9623425a806c85cdb6f0e0f7
#include <stdio.h> int main() { char a[100000]; int j=0,k=0,i=0; while(a[i-1]!='\n') { scanf("%c",&a[i]); if(a[i]=='\n') { break; } if((a[i]-'0')%2==0) { j=j+1; i++; }else if((a[i]-'0')%2==1){ k=k+1; i++; } } if((a[i-1]-'0')%2==0) { printf("%d",j-1); }else{ printf("%d",k-1); } return 0; }