回复 10楼 return_0
如果是 20位的正整数呢?

https://zh.cppreference.com
#include<stdio.h> int main() { int nBit = 0; int nSum = 0; int ch; while((ch = getchar()) != '\n') { ++nBit; nSum += ch - '0'; } printf("%d %d", nBit, nSum); return 0; }