文章

211

粉丝

1

获赞

1181

访问

83.3k

头像
字符个数 题解:
P1042 重庆大学机试题
发布于2026年3月18日 19:41
阅读数 236

#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
	getline(cin,str);
	int alpha=0,digit=0,blank=0,other=0;
	for(char c:str){
		if(isalpha(c))
			alpha++;
		else if(isdigit(c))
			digit++;
		else if(c == ' ')
			blank++;
		else
			other++;
	}	
	cout << alpha << " " << digit << " " << blank << " " << other;
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发