-
Notifications
You must be signed in to change notification settings - Fork 1
/
Count_the_substring.c
67 lines (62 loc) · 1.17 KB
/
Count_the_substring.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <string.h>
int isUpper(char c){
int ascii = (int)c;
if (ascii >= 65 && ascii <=90)
{
return 1;
}
else{
return 0;
}
}
int isLower(char c){
int ascii = (int)c;
if (ascii >= 97 && ascii <=122)
{
return 1;
}
else{
return 0;
}
}
int match(char s[],int start,int end){
int cu=0,cl=0;
for (int i = start; i <= end; i++)
{
if (isLower(s[i]))
{
cl++;
}
else if(isUpper(s[i])){
cu++;
}
}
if (cl==cu)
{
return 1;
}
else{
return 0;
}
}
int countSubString(char s[],int len){
int count_lower=0,count_upper=0,j;
for (int i = 0; i < len; i++)
{
for ( j = i; j < len; j++)
{
if(match(s,i,j)){
printf("(%d,%d)",i,j);
}
}
}
}
int main()
{
char s[] = "gEEk";
int len = strlen(s);
countSubString(s,len);
// printf("%d",match(s,3,7));
return 0;
}