C语言实现字符串子串统计
#include <stdio.h>
int main() { char str[100001]; scanf('%s', str);
int count = 0;
int i = 0;
while (str[i] != '\0') {
if (str[i] == '1') {
count++;
}
i++;
}
int answer = count * (count + 1) / 2;
printf('%d\n', answer);
return 0;
}
原文地址: https://www.cveoy.top/t/topic/o19C 著作权归作者所有。请勿转载和采集!