萌新求助
查看原帖
萌新求助
1236981
Axxx666楼主2024/6/6 21:08

两个例子和第一个测试点的数据在电脑上可以用而且答案一样,但依旧全RE。 原因是答案太短了。。。。 附代码


#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    string str;
    cin.get();
    getline(cin,str);
    vector<int> name;
    bool god=true;
    int count=0;
    for(int i=0; i<str.length(); i++){
        if(str[i]>='A'&&str[i]<='Z'){
            for(int j=i+1; j<str.length(); j++){
                if(str[j]==' '||(str[j]=='.'||str[j]=='?'||str[j]=='!')){
                    break;
                }
                if(isdigit(str[j])){
                    god=false;
                    break;
                }
                if(str[j]>='A'&&str[j]<='Z'){
                    god=false;
                    break;
                }
            }
            if(god){
                count++;
            }
            god=true;
        }
        if(str[i]=='.'||str[i]=='?'||str[i]=='!'){
            name.push_back(count);
            count=0;
        }
    }
    for(int i=0; i<name.size(); i++){
        cout<<name[i]<<endl;
    }
    return 0;
}
2024/6/6 21:08
加载中...