답안 #238305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238305 2020-06-10T18:22:47 Z marlicu Imena (COCI16_imena) C++14
50 / 50
5 ms 384 KB
#include <bits/stdc++.h>

using namespace std;


int ime(string s) {
    if (s[0] < 'A' || s[0] > 'Z') return 0;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] < 'a' || s[i] > 'z') return 0;
    }
    return 1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    string n, s;
    getline(cin, n);
    getline(cin, s);

    int imena = 0;
    string rijec;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '.' || s[i] == '?' || s[i] == '!') {
            if (ime(rijec)) imena++;
            cout << imena << '\n';
            imena = 0;
            rijec = "";
        }
        else if (s[i] == ' ') {
            if (ime(rijec)) imena++;
            rijec = "";
        }
        else rijec += s[i];
    }

    return 0;
}

Compilation message

imena.cpp: In function 'int ime(std::__cxx11::string)':
imena.cpp:8:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < s.size(); i++) {
                     ~~^~~~~~~~~~
imena.cpp: In function 'int main()':
imena.cpp:25:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++) {
                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct