#K93377. Cyclomatic Complexity Calculator
Cyclomatic Complexity Calculator
Cyclomatic Complexity Calculator
You are given a series of test cases. In each test case, you are provided two integers E and N which denote the number of edges and nodes in a control flow graph respectively. The cyclomatic complexity CC is defined by the formula: \( CC = E - N + 2 \) (assuming a single connected component, i.e. \( P = 1 \)). Your task is to compute the cyclomatic complexity for each test case.
Input: The first line of input contains an integer T representing the number of test cases. Each of the next T lines contains two space-separated integers, E and N.
Output: For each test case, output a single integer denoting the cyclomatic complexity. Each result should be printed on its own line.
inputFormat
The input is read from standard input and has the following format:
T E1 N1 E2 N2 ... ET NT
Where T is the number of test cases. Each test case contains two integers E and N separated by space.
outputFormat
For each test case, output the computed cyclomatic complexity, each on a new line. The cyclomatic complexity is computed using the formula:
CC = E - N + 2## sample
5
10 7
15 10
5 5
20 15
0 0
5
7
2
7
2
</p>