#include <stdio.h> #include <string.h>

int main() { char str[100]; int count = 0;

printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
str[strcspn(str, "\n")] = '\0'; // Remove the newline character

for (int i = 0; i < strlen(str); i++) {
    if (str[i] != '(' && str[i] != ')') {
        count++;
    }
}

printf("Number of characters that are not '(' or ')' is %d\n", count);

return 0;

}

求字符串中的不是 和字符的个数给出C语言代码

原文地址: https://www.cveoy.top/t/topic/ilJr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录