Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int dias=0,i=0,x=0,y=0,cont=0;
- scanf("%d", &dias);
- char letra[dias];
- for(i=0;i<dias;i++)
- {
- scanf("%s", &letra[i]);
- switch(letra[i])
- {
- case 'D':
- {
- x++;
- if(x > y)
- {
- if(x-1 == y && x-2 < y)
- {
- if(letra[i-1] != 'C')
- {
- cont++;
- }
- }
- }
- break;
- }
- case 'C':
- {
- y++;
- if(x < y)
- {
- if(y-1 == x && y-2 < x)
- {
- if(letra[i-1] != 'D')
- {
- cont++;
- }
- }
- }
- break;
- }
- }
- }
- if(cont==0)
- {
- printf("%d", cont);
- }
- else
- {
- printf("%d", cont-1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement