fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4. int n,i,j,k,l[5],b=0,c=0,h=0,t=0;
  5. char str[5],s[5];
  6. printf("enter no of records to be analyzed");
  7. scanf("%d",&n);
  8. for(i=1;i<=n;i++)
  9. {
  10. scanf("%d",&l[i]);
  11. scanf("%s",&str[i]);
  12. }
  13. for(i=1;i<=n;i++)
  14. {
  15. b=0;
  16. c=0;
  17. strcpy(s,str[i]);
  18. for(k=0;k<l[i];k++)
  19. {
  20. if(s[k]==46)
  21. continue;
  22. if(s[k]==72)
  23. {
  24. if(b==1)
  25. {
  26. printf("invalid");
  27. break;
  28. }
  29. b=1;
  30. c=0;
  31. h++;
  32. }
  33. if(s[k]==84)
  34. {
  35. if(c==1||b==0)
  36. {
  37. printf("invalid");
  38. break;
  39. }
  40. c=1;
  41. b=0;
  42. t++;
  43. }
  44. }
  45. if((k==l[i]) && (h==t))
  46. {
  47. printf("valid");
  48. }
  49. }
  50. return 0;
  51. }
  52.  
Runtime error #stdin #stdout 0s 9432KB
stdin
2
3
HT.
4
HT..
stdout
Standard output is empty