Skip to content

Commit a7ae7e3

Browse files
committed
alter 5.3.cpp
1 parent d6523d4 commit a7ae7e3

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

1.7

48 Bytes
Binary file not shown.

1.7.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
using namespace std;
55

66
void zero(int **a, int m, int n){
7-
bool *row = new bool[m];
8-
bool *col = new bool[n];
7+
bool row[m], col[n];
98
memset(row, false, sizeof(row));
109
memset(col, false, sizeof(col));
1110
for(int i=0; i<m; ++i)

5.3.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ int next(int x){
2222
int num = count_one(x);
2323
if(num == 0 || x == -1) return -1;
2424
for(++x; count_one(x) != num && x <= max_int; ++x);
25-
if(x == max_int) return -1;
26-
return x;
25+
if(count_one(x) == num) return x;
26+
return -1;
2727
}
2828
int previous(int x){
2929
int min_int = (1<<31);
3030
int num = count_one(x);
3131
if(num == 0 || x == -1) return -1;
3232
for(--x; count_one(x) != num && x >= min_int; --x);
33-
if(x == min_int) return -1;
34-
return x;
33+
if(count_one(x) == num) return x;
34+
return -1;
3535
}
3636
int next1(int x){
3737
int xx = x, bit = 0;

0 commit comments

Comments
 (0)