Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- const int n = 256;
- int len1, len2;
- char voc[] = "aAeEiIoOuU";
- bool str_find(const char* source, const char c)
- {
- for (const char* pch = source; *pch; pch++) {
- if (*pch == c) {
- return 1;
- }
- }
- return 0;
- }
- int str_comp(char* str1, char* str2)
- {
- if (*str1 && *str2) {
- if (str_find(voc, *str1)) {
- len1++;
- }
- if (str_find(voc, *str2)) {
- len2++;
- }
- return str_comp(str1 + 1, str2 + 1);
- } else if (*str1) {
- if (str_find(voc, *str1)) {
- len1++;
- }
- return str_comp(str1 + 1, str2);
- } else if (*str2) {
- if (str_find(voc, *str2)) {
- len2++;
- }
- return str_comp(str1, str2 + 1);
- } else {
- if (len1 == len2) {
- return 0;
- } else if (len1 > len2) {
- return 1;
- } else {
- return 2;
- }
- }
- }
- int main()
- {
- char str1[n], str2[n];
- printf("Sirul 1: ");
- scanf("%s", str1);
- printf("Sirul 2: ");
- scanf("%s", str2);
- int res = str_comp(str1, str2);
- printf("%d\n", res);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement