首页 > 字符统计
头像 李华plus
发表于 2021-10-16 11:37:22
C标准中有一个一个头文件<ctype.h>,这里面定义了一批C语言字符处理函数,用于测试字符是否属于特定的字符类别 #include<stdio.h> #include<ctype.h> int main() {    &nbs 展开全文
头像 我是一只小肚肚
发表于 2021-02-23 14:08:26
注意小心边界值,字母还要考虑大写 int main() { char a; int Letters = 0, Digits = 0, Others = 0; while ((a = getchar()) != '?') { if ((a >= ' 展开全文
头像 晨曦挣大钱
发表于 2020-09-24 10:17:03
python Letters = 0 Digits = 0 Others = 0 x = input() for i in x: if i.isdigit(): Digits += 1 elif i.isalpha(): Letters += 1 展开全文
头像 frlpp
发表于 2021-05-30 14:36:19
#include <bits/stdc++.h> using namespace std; int main() { char c; c = getchar(); int Letters = 0,Digits = 0,Others = 0; while 展开全文
头像 Codecodify
发表于 2023-05-18 16:41:48
通过ascii码表来对比整数大小,当然这解法不简洁,看评论的解法都挺优雅的。 #include <stdio.h> int main() { int letters = 0, digits = 0, others = 0, assic = 0; char c; 展开全文
头像 牛客517072235号
发表于 2021-08-02 16:01:46
#include<iostream> using namespace std; int main() { char a; int l=0, d=0, o=0; do { a=getchar(); if((a>='a'& 展开全文
头像 杨离
发表于 2021-10-18 20:22:52
暴力求解 #include<stdio.h> #include<string.h> int main(){ char a[100]; gets(a); int i=0; while(a[i]!='?'){ i++; } int zm=0,s 展开全文
头像 Kennywu
发表于 2024-12-30 15:35:10
// 使用 %[^\n] 来读取整行输入,包括空格 #include<stdio.h> #include<string.h> int main(){     char s[1000]; 展开全文
头像 Lysss_
发表于 2024-03-02 14:11:41
#include <cctype> using namespace std; int main() { int Letters = 0,Digits = 0,Others = 0; char a; cin.get(a); while (a != '?') 展开全文
头像 AmzingWork
发表于 2023-04-11 13:32:24
代码如下: #include <iostream> using namespace std; char ch; int cnt[3]; int classify(char ch) { if (ch >= 'A' && ch <= 'Z' || ch & 展开全文