CodeBlocks ignore to print a line!!
Apr 24, 2015 at 3:07pm UTC
When i debug this code the debugger ignore line 97 and 99 and doesn't print it !? Why and How to fix it ??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int calc(int *a,int (*matrix)[2])
{
int res = 0;
for (int i=0;i<sizeof (matrix);i++)
{
int x,y;
int num;
int num1;
int temp;
int index = 0;
int index2 = 0;
bool s1 = 0;
bool s2 = 0;
int mid = sizeof (a);
int mid2 = sizeof (a);
int j = 0;
int point1[2];
int point2[2];
point1[0] = 0;
point2[0] = 0;
point1[1] = 0;
point2[1] = 0;
bool sign1 = 1;
bool sign2 = 1;
while (!(s1&&s2))
{
x = (index)+(((mid-index))/2);
y = (index)+(((mid-index+1))/2);
if (a[x]>=matrix[i][0]&&!s1)////////////////////////////////
{
num = x;
sign1 = 0;
if (mid==index)
{
point1[0] = num;
point2[1] = -1;
s1 = !s1;
}
mid = num;
}
else if (!s1)
{
num = y;
if (mid==index)
{
point1[0] = num;
point1[1] = 1;
s1 = !s1;
}
index = num;
}
x = (index2)+(((mid2-index2))/2);
y = (index2)+(((mid2-index2+1))/2);
if (a[x]>=matrix[i][1]&&!s2)
{
num1 = x;
if (mid2==index2)
{
point2[0] = num1;
point2[1] = -1;
s2 = !s2;
}
mid2 = num1;
}
else if (!s2)
{
num1 = y;
if (mid2==index2)
{
point2[0] = num1;
point2[1] = 1;
s2 = !s2;
}
index2 = num1;
}
}
x = point1[0];
y = point2[0];
if (point1[0]<point2[0])
{
if ((point1[1]==1&&point2[1]==1)||(point1[1]==-1&&point2[1]==-1))
{
res = res + (point2[0]-point1[0]);
}
else if ((point1[1]==-1&&point2[1]==1)||(point1[1]==1&&point2[1]==-1))
{
cout<<res<< endl;
res = res + (point2[0]-point1[0]-1);//////////////
cout<<res<< endl;
}
}
else
{
if ((point1[1]==1&&point2[1]==1)||(point1[1]==-1&&point2[1]==-1))
{
res += point1[0]-point2[0];
}
else if ((point1[1]==-1&&point2[1]==1)||(point1[1]==1&&point2[1]==-1))
{
res += point1[0]-point2[0]-1;
}
}
}
return res;
}
int main()
{
...........
return 0;
}
Last edited on Apr 24, 2015 at 3:09pm UTC
Apr 24, 2015 at 3:16pm UTC
the debugger ignore line 97 and 99 and doesn't print it !?
1 2 3 4 5 6 7 8 9 10
if ((point1[1]==1&&point2[1]==1)||(point1[1]==-1&&point2[1]==-1))
{
res = res + (point2[0]-point1[0]);
}
else if ((point1[1]==-1&&point2[1]==1)||(point1[1]==1&&point2[1]==-1))
{
cout<<res<< endl;
res = res + (point2[0]-point1[0]-1);//////////////
cout<<res<< endl;
}
You see you have added a if-else condition...
if the
if
statement is true it will execute it and ignore the
else .
...
That totally depends on the logic of code and what are you trying to implement...
Last edited on Apr 24, 2015 at 3:18pm UTC
Apr 24, 2015 at 3:20pm UTC
but the debugger passed on line 98 and didn't print that in line 97 and 99 ?
Apr 24, 2015 at 3:44pm UTC
did it pass through line 93?
Topic archived. No new replies allowed.