牛客网通过版while(getline(cin,str))

#include <iostream>
#include <string>
using namespace std;
#include <stdio.h>
#include <memory.h>
#define MAXLEN 250
int largelettersize(const char* str)
{
    int len = strlen(str);
    if(len > MAXLEN)
        return -1;
    int size = 0;
    do
    {
        if(*str >= 'A' && *str <= 'Z')
            size++;
    }while(*str++ != '\0');
 
    return size;
}
 
int main()
{
   int i = 0;
   string str;
  while (getline(cin,str))
    cout<<largelettersize(str.c_str())<<endl;  
           
 
}

  

 

posted on 2021-12-02 14:19  lydstory  阅读(148)  评论(0)    收藏  举报

导航