-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.c
59 lines (51 loc) · 1.11 KB
/
edit.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
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define MAX 1002
inline int min (int a , int b){
if (a < b)
return a ;
else
return b ;
}
int main ()
{
char str[MAX];
int i , even[3] , odd[3] , ans , length , temp;
//scanf ("%s",str) ;
while (scanf ("%s",str) != EOF){
even[0] = 0 ;
even[1] = 0 ;
odd[0] = 0 ;
odd[1] = 0 ;
length = strlen(str) ;
for (i = 0 ; i< length ; i++ ) {
// for odd position of the string
if (i%2 == 0){
//checking whether it is uppercase of lowercase
temp = str[i] ;
//printf ("%c",str[i]) ;
//printf ("%d %d %d %d %d\n",even[0] , even[1] , odd[0] , odd[1] , temp) ;
if (isupper(temp))
odd[1] ++ ;
else
odd[0] ++ ;
}
//for even position of the string
else {
//checking the case of the string
temp = str[i] ;
//printf ("%c",str[i]) ;
//printf ("%d %d %d %d %d\n",even[0] , even[1] , odd[0] , odd[1] , temp) ;
if (isupper(temp))
even[1] ++ ;
else
even[0]++ ;
}
}
ans = min (even[0]+odd[1], even[1] + odd[0]) ;
printf ("%d\n",ans);
//scanf ("%s",str) ;
}
return 0 ;
}