Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int is_match_result( char *s )
- {
- int i=1;
- if(!isalpha(s[0]))
- return 0;
- while(s[i]!=' '){
- if(!((isalnum(s[i]))||s[i]=='-'))
- return 0;
- if(s[i]=='-'){
- if(!(isalpha(s[i-1])))
- return 0;
- if(!(isalpha(s[i+1])))
- return 0;}
- i++;
- }
- if(!(isalpha(s[i-1])))
- return 0;
- if(s[i]!=' ') return 0; i++;
- if(s[i]!='-') return 0; i++;
- if(s[i]!=' ') return 0; i++;
- if(!isalpha(s[i])) return 0; i++;
- while(s[i]!=' '){
- if(!((isalnum(s[i]))||s[i]=='-'))
- return 0;
- if(s[i]=='-'){
- if(!(isalpha(s[i-1])))
- return 0;
- if(!(isalpha(s[i+1])))
- return 0;}
- i++;
- }
- if(s[i]!=' ') return 0; i++;
- while(s[i]!=':'){
- if(!isdigit(s[i])) return 0;
- i++;
- }
- if(s[i]!=':') return 0;
- i++;
- for(;s[i];i++){
- if(!isdigit(s[i])) return 0;
- }
- return 1;
- }
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- char line[ 1000 ];
- int is_match_result( char * );
- while ( gets( line ) != NULL )
- if ( is_match_result( line ) )
- puts( "YES" );
- else
- puts( "NO" );
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement