Submission #703977

# Submission time Handle Problem Language Result Execution time Memory
703977 2023-03-01T07:54:46 Z vjudge1 Imena (COCI16_imena) C++11
50 / 50
1 ms 212 KB
#include <bits/stdc++.h>

using namespace std;


int main() {
	int n;
	cin >> n;
	getchar();
	string s;
	getline(cin, s);
	s += ' ';
	int ans = 0, flag = 0, down = 0, b = 1;
	for (int j = 0; j < s.size(); ++j) {
		char  ss = s[j];
		if (ss == ' '){
			if (flag == 1) ans++, flag = 0;
			if (s[j-1] == '.' || s[j-1] == '?' || s[j-1] == '!') {
				cout << ans << endl;
				ans = 0, flag = 0;
			}
		}
		else if (ss >= 'A' && ss <= 'Z') flag = 1;
		else if (!((ss >= 'A' && ss <= 'Z') || (ss >= 'a' && ss <= 'z')) && ss != '.' && ss != '!' && ss != '?' ) flag = 0; 
	}
}

Compilation message

imena.cpp: In function 'int main()':
imena.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int j = 0; j < s.size(); ++j) {
      |                  ~~^~~~~~~~~~
imena.cpp:13:25: warning: unused variable 'down' [-Wunused-variable]
   13 |  int ans = 0, flag = 0, down = 0, b = 1;
      |                         ^~~~
imena.cpp:13:35: warning: unused variable 'b' [-Wunused-variable]
   13 |  int ans = 0, flag = 0, down = 0, b = 1;
      |                                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct