Skip to content

Commit 2d374f4

Browse files
author
MayuriNFC
committed
fix type warning
1 parent c876e10 commit 2d374f4

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

c/bubblesort/include/bubblesort.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
#define _bubblessort_h
33
#include <stdio.h>
44
#include <stdlib.h>
5-
int *bubblesort(int *array);
5+
void *bubblesort(int *array);
66
#endif

c/bubblesort/src/bubble.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
#include "../include/bubblesort.h"
2-
int main(){
3-
int a[] = {1,2,3,4,5,6,7,8,9,10};
2+
int main()
3+
{
4+
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
45
int i;
5-
for (i=0;i<sizeof(a)/sizeof(a[0]);i++){
6-
printf("%d\n",a[i]);
6+
for (i = 0; i < sizeof(a) / sizeof(a[0]); i++)
7+
{
8+
printf("%d\n", a[i]);
79
}
810
return 0;
911
}
10-
int *bubblesort(int *array){
11-
int i,j,temp;
12-
for (i=0;i<sizeof(array)/sizeof(array[0]);i++){
13-
for (j=0;j<sizeof(array)/sizeof(array[0])-i-1;j++){
14-
if (array[j]>array[j+1]){
15-
temp =array[j];
16-
array[j]=array[j+1];
17-
array[j+1]=temp;
12+
void *bubblesort(int array[])
13+
{
14+
int i, j, temp;
15+
for (i = 0; i < sizeof(array) / sizeof(array[0]); i++)
16+
{
17+
for (j = 0; j < sizeof(array) / sizeof(array[0]) - i - 1; j++)
18+
{
19+
if (array[j] > array[j + 1])
20+
{
21+
temp = array[j];
22+
array[j] = array[j + 1];
23+
array[j + 1] = temp;
1824
}
1925
}
2026
}
21-
return *array;
2227
}

0 commit comments

Comments
 (0)