Skip to content

Commit f1a4a18

Browse files
committedMar 26, 2015
fix compiler warnings
1 parent 4b96bb9 commit f1a4a18

File tree

8 files changed

+32
-22
lines changed

8 files changed

+32
-22
lines changed
 

‎src/121.c

+2-1
Large diffs are not rendered by default.

‎src/122.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ int maxProfit(int prices[], int n){
3232
int main() {
3333
int prices[] = {1, 2, 3, 2, 4};
3434
printf("%d\n", maxProfit(prices, sizeof(prices)/sizeof(prices[0])));
35-
}
35+
return 0;
36+
}

‎src/150.c

+1
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ int main()
7777
{
7878
char *tokens[] = {"3","-4","+"};
7979
printf("%d\n", evalRPN(tokens, sizeof(tokens)/ sizeof(tokens[0])));
80+
return 0;
8081
}
8182

‎src/151.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ int main()
5959
char s[] = " the sky is blue ";
6060
reverseWords(s);
6161
printf("%s\n", s);
62-
}
62+
return 0;
63+
}

‎src/165.c

+1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ int main() {
6161
char v2[] = "19.8.3.17.5.01.0.0.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0000.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.000000";
6262

6363
printf("%d\n", compareVersion(v1, v2));
64+
return 0;
6465
}

‎src/1_hash.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ int main() {
7878
printf("index%d = %d ", i + 1, index[i]);
7979
}
8080
printf("\n");
81-
82-
}
81+
return 0;
82+
}

‎src/1_qsort.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ typedef struct {
88

99
int compar(const void *p1, const void *p2) {
1010
if (((Node *)p1)->data < ((Node *)p2)->data) return -1;
11-
if (((Node *)p1)->data == ((Node *)p2)->data) return 0;
12-
if (((Node *)p1)->data > ((Node *)p2)->data) return 1;
11+
else if (((Node *)p1)->data > ((Node *)p2)->data) return 1;
12+
else return 0;
1313
}
1414

1515
int *twoSum(int numbers[], int n, int target) {
@@ -59,5 +59,5 @@ int main() {
5959
printf("index%d = %d ", i + 1, index[i]);
6060
}
6161
printf("\n");
62-
63-
}
62+
return 0;
63+
}

‎src/8.c

+18-13
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,24 @@ int myAtoi(char *str) {
3232
}
3333

3434
int main() {
35-
char *s1 = " 123 ";
36-
char *s2 = "123.4";
37-
char *s3 = "-1234";
38-
char *s4 = "2147483646";
39-
char *s5 = "2147483647";
40-
char *s6 = "2147483648";
41-
char *s7 = "-2147483647";
42-
char *s8 = "-2147483648";
43-
char *s9 = "-2147483649";
44-
char *s10 = "-1";
45-
char *s11 = "+-2";
46-
char *s12 = "9223372036854775809";
47-
printf("%d\n", myAtoi(s12));
35+
char *s[12];
36+
s[0] = " 123 ";
37+
s[1] = "123.4";
38+
s[2] = "-1234";
39+
s[3] = "2147483646";
40+
s[4] = "2147483647";
41+
s[5] = "2147483648";
42+
s[6] = "-2147483647";
43+
s[7] = "-2147483648";
44+
s[8] = "-2147483649";
45+
s[9] = "-1";
46+
s[10] = "+-2";
47+
s[11] = "9223372036854775809";
48+
49+
int i;
50+
for (i = 0; i < 12; i++)
51+
printf("%d\n", myAtoi(s[i]));
52+
4853
return 0;
4954
}
5055

0 commit comments

Comments
 (0)