在主函数中定义一个长度为50的char型数组,使用gets函数为该数组从键盘赋值,统计该数组中大写字母的个数

日期:2016-11-11 12:00:35 人气:3

在主函数中定义一个长度为50的char型数组,使用gets函数为该数组从键盘赋值,统计该数组中大写字母的个数

1. #include #include using namespace std;int main(){ char str[50]; printf("请输入你的字符串:\n"); gets(str); int len = strlen(str); int sum = 0; for(int i=0;i='A'&&str[i]<='Z') sum++; puts(str);
    A+
热门评论