#include <stdio.h>
int main() {char c;int word, blank, number, other,i,n;word = 0;blank = 0;number = 0;other = 0;printf("请输入一个正整数n:n");scanf("%d",&n);printf("请输入一串字符:n");for (i = 0; i <= n; i++) {scanf("%c", &c);if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {word++;} else if (c == ' ') {blank++;} else if (c >= '0' && c <= '9') {number++;} else {other++;}}printf("该字符中英文字母word=%d,空格有blank=%d,数字有number=%d,其他字符有other=%d",word,blank,number,other);return 0;
}
本文发布于:2024-02-03 07:35:57,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170691695749575.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |