Advertisement
zsoltizbekk

labda

Apr 14th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int is_match_result( char *s )
  5.  {
  6.    int i=1;
  7. if(!isalpha(s[0]))
  8.    return 0;
  9.  
  10. while(s[i]!=' '){
  11.  if(!((isalnum(s[i]))||s[i]=='-'))
  12.    return 0;
  13.  if(s[i]=='-'){
  14. if(!(isalpha(s[i-1])))
  15.    return 0;
  16.  if(!(isalpha(s[i+1])))
  17.    return 0;}
  18.  i++;
  19. }
  20.  
  21. if(!(isalpha(s[i-1])))
  22.   return 0;
  23.  
  24. if(s[i]!=' ') return 0; i++;
  25. if(s[i]!='-') return 0; i++;
  26. if(s[i]!=' ') return 0; i++;
  27.  
  28.  
  29. if(!isalpha(s[i])) return 0; i++;
  30.  while(s[i]!=' '){
  31.  if(!((isalnum(s[i]))||s[i]=='-'))
  32.    return 0;
  33.  if(s[i]=='-'){
  34.  if(!(isalpha(s[i-1])))
  35.    return 0;
  36.  if(!(isalpha(s[i+1])))
  37.    return 0;}
  38.   i++;
  39. }
  40. if(s[i]!=' ') return 0; i++;
  41. while(s[i]!=':'){
  42.   if(!isdigit(s[i])) return 0;
  43.      i++;
  44. }
  45.  
  46. if(s[i]!=':') return 0;
  47. i++;
  48.      for(;s[i];i++){
  49.       if(!isdigit(s[i])) return 0;
  50.  
  51.  
  52. }
  53. return 1;
  54. }
  55.  
  56.  
  57. #include <stdio.h>
  58. #include <stdlib.h>
  59. int main()
  60. {
  61.   char line[ 1000 ];
  62.   int is_match_result( char * );
  63.   while ( gets( line ) != NULL )
  64.     if ( is_match_result( line ) )
  65.       puts( "YES" );
  66.     else
  67.       puts( "NO" );
  68.   return EXIT_SUCCESS;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement