Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
816 B
3
Indexable
Never
#include <stdio.h>
#include <stdbool.h>

// Function to check if the string contains the substring "aa"
bool containsSubstringAA(const char* input) {
	int i = 0;
    // Traverse the string and check for "aa"
    for ( i = 0; input[i] != '\0'; i++) {
        if (input[i] == 'a' && input[i + 1] == 'a') {
            return true; // Found "aa"
        }
    }
    return false; // Did not find "aa"
}

int main() {
    char input[100];

    // Get user input
    printf("Enter a string with symbols 'a' and 'b': ");
    scanf("%s", input);

    // Check if the string contains "aa"
    if (containsSubstringAA(input)) {
        printf("The string contains the substring 'aa'.\n");
    } else {
        printf("The string does not contain the substring 'aa'.\n");
    }

    return 0;
}
Leave a Comment