Guest User

Untitled

a guest
Oct 21st, 2019
297
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. char s[100];
  7. for (int i = 0; i < 100; i++)
  8. {
  9. scanf("%c", &s[i]);
  10. if (s[i] == '\n')
  11. {
  12. s[i] == '\0';
  13. break;
  14. }
  15. }
  16.  
  17. int a = 0, b = 0, c = 0;
  18. int t = 0;
  19. for (int i = 0; i < strlen(s); i++)
  20. {
  21. if (s[i] == '(')
  22. {
  23. a++;
  24. for (int j = t + 1; j < strlen(s); j++)
  25. {
  26. if (s[j] == ')')
  27. {
  28. b++;
  29. t = j;
  30. break;
  31. }#include <stdio.h>
  32. #include <string.h>
  33.  
  34. int main()
  35. {
  36. char s[100];
  37. for (int i = 0; i < 100; i++)
  38. {
  39. scanf("%c", &s[i]);
  40. if (s[i] == '\n')
  41. {
  42. s[i] == '\0';
  43. break;
  44. }
  45. }
  46.  
  47. int a = 0, b = 0, c = 0;
  48. int t = 0;
  49. for (int i = 0; i < strlen(s); i++)
  50. {
  51. if (s[i] == '(')
  52. {
  53. a++;
  54. for (int j = t + 1; j < strlen(s); j++)
  55. {
  56. if (s[j] == ')')
  57. {
  58. b++;
  59. t = j;
  60. break;
  61. }
  62. }
  63. } else {
  64. if (s[i] == ')')
  65. c++;
  66. }
  67. }
  68.  
  69. printf("a = %d, b = %d, c = %d\n", a, b, c);
  70. printf("%d\n", (a == b && c == b) ? 1 : 0);
  71. return 0;
  72. }
  73. }
  74. } else {
  75. if (s[i] == ')')
  76. c++;
  77. }
  78. }
  79.  
  80. printf("a = %d, b = %d, c = %d\n", a, b, c);
  81. printf("%d\n", (a == b && c == b) ? 1 : 0);
  82. return 0;
  83. }
RAW Paste Data