首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
阿灿
2025年3月15日 20:31
字符个数 题解:我还是慢了
P1042
回复 1
|
赞 3
|
浏览 435
#include<bits/stdc++.h> using namespace std; int main(){ string n; getline(cin,n); int a1=0,a2=0,a3=0,a4=0; for(char a:n){ if(a>='A'&&a<='Z'||a>='a'&&a<='z'){ a1++; }else if(a>='0'&&a<='9'){ a2++; }else if(a == ' '){ ...
wuhududu
2025年3月2日 20:43
字符个数 题解:
P1042
回复 0
|
赞 0
|
浏览 511
#include<bits/stdc++.h> using namespace std; char s[1000]; int main() { gets(s); int len =strlen(s); int a=0,b=0,c=0,d=0; for(int i=0;i<len;i++) { &nbs...
Candour
2024年5月21日 23:48
字符个数(C++) 题解:
P1042
回复 0
|
赞 8
|
浏览 760
#include<bits/stdc++.h> using namespace std; string str; int a, b, c, d; int main() { getline(cin, str); for(int i = 0; i < str.size(); i ++) { if(isalpha(str[i])) a ++; else if(isalnum(str[i])) b ++; else if(str[i] == ' ') c ++; else d ++; } cout ...
huanghu
2024年3月16日 15:00
字符个数 题解:C++
P1042
回复 0
|
赞 4
|
浏览 741
#include<stdio.h> #include<string> #include<iostream> using namespace std; int main(){ int ch=0,shu=0,kong=0,el=0; string str; getline(cin,str); int len = str.length(); for(int i = 0; i<len; i++){ if(str[i]>='0'&&str[i]<='9'){ shu++; ...
小酒
2024年3月15日 15:33
字符个数 题解:
P1042
回复 0
|
赞 1
|
浏览 697
1042解题思路 #include <bits/stdc++.h> using namespace std; int main() { int num=0,str=0,zero=0,other=0; char a[105]={0}; gets(a); int l=strlen(a); for(int i=0;i<l;i++) { if(a[i]>='0'&&a[i]<='9') num++; else { if(a[...
williams
2024年3月6日 11:00
字符个数 题解:c
P1042
回复 0
|
赞 3
|
浏览 1.0k
#include <stdio.h> #include <stdbool.h> #include <math.h> #include <string.h> int main(void) { char s[1000]; int eng=0,math=0,space=0,c=0; gets(s); for(int i=0;i<strlen(s);i++){ if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&...
活着的传奇
2023年8月21日 10:17
字符个数 题解:
P1042
回复 0
|
赞 0
|
浏览 881
#include<bits/stdc++.h> using namespace std; int main(){ char a; int x =0,b = 0,c = 0,d =0; while((a =getchar())!='\n') { if(a>='0'&&a<='9') x++; else if((a>='a'&&a<='z')||(a>='A'&&a<='Z')) b++; else if(a...
dongqing
2023年7月27日 12:48
字符个数
P1042
回复 0
|
赞 2
|
浏览 1.1k
string s; getline(cin,s); 采用这种输入方式可以输入空格 #include<bits/stdc++.h> using namespace std; int main(){ string s; int zimu=0,shuzi=0,kongge=0,qita=0; getline(cin,s); for(int i=0;i<s.size();i++) { if(s[i]>='a'&&s[i]<='z') ...
Hegel
2023年3月24日 19:28
统计字符串s中字母数字空格以及其他字符的个数
P1042
回复 0
|
赞 1
|
浏览 2.4k
#include <iostream> #include <string> using namespace std; int main() { int e=0,n=0,b=0,o=0; string s; getline(cin,s); for(int i=0;i<s.size();i++){ if(s[i]>='a'&&s[i]<='z'||s[i]>='A'&&s[i]<='Z') e++; else if(s[i]>='0'&&s...
零壹
2023年3月23日 11:34
c-gets()
P1042
回复 0
|
赞 0
|
浏览 2.7k
注意用gets()来接收字符串即可,因为用scanf()的话,输入过程中有空格会很麻烦 #include<stdio.h> #include<string.h> int main(){ char str[100]; gets(str); int len=strlen(str); int p=0,q=0,t=0,m=0; for(int i=0;i<len;i++){ if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&...
1
2
题目
字符个数
题解数量
13
发布题解
在线答疑
热门题解
1
字符个数(C++) 题解:
2
字符个数 题解:C++
3
字符个数 题解:我还是慢了
4
字符个数 题解:c
5
字符个数
6
统计字符串s中字母数字空格以及其他字符的个数
7
TA zai 跟我开玩笑 没ch=a[i]就是不给通过
8
字符个数 题解:
9
字符个数 题解:
10
字符个数(c++)