Слишком большое условие, за код извиняюсь ,заранее спасибо
#include <iostream>
#include <fstream>
using namespace std;
int main() {
const int n = 255;
char text[n];
ifstream file;
file.open("Text.txt");
while (file.get(text, n))
{
cout << "Text in txt file: " << text;
}
file.close();
cout << text << endl;
int sum = 0, open = 0, close = 0;
for (int i = 0; i < n; i++)
{
if (text[i] == '(')
{
open = open + 1;
}
else if (text[i] == ')')
{
close = close + 1;
if (close == open && close != 0 && open != 0)
{
sum = sum + close, close = 0, open = 0;
}
}
else
if (open > close)
{
sum = sum + close, close = 0, open = 0;
}
if (open < close)
{
sum = sum + open, close = 0, open = 0;
}
}
cout << "Correct brackets: " << sum;
}