Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool space(char ch) {
- if (ch == ' ' || ch == '\t' || ch == '\0')
- return true;
- return false;
- }
- int strlen(char* str) {
- int counter = 0;
- while (str[counter] != '\0') {
- ++counter;
- }
- return counter;
- }
- int evenWords(char* str) {
- int result = 0;
- int len = strlen(str);
- int counter = 0;
- for (int i = 0; i < len; i++) {
- if (!space(str[i])){
- ++counter;
- }
- else {
- if (counter % 2 == 0) {
- ++result;
- }
- counter = 0;
- }
- }
- return result;
- }
- int main() {
- char arr[] = "this is arr";
- evenWords(arr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement