projects
/
openpower-isa.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
more crap removed
[openpower-isa.git]
/
maxloc
/
maxloc.c
1
#include<stdio.h>
2
3
int
m2
(
int
*
a
,
int
n
)
4
{
5
int
m
,
nm
;
6
int
i
;
7
8
m
=
0
;
9
nm
= -
1
;
10
i
=
0
;
11
while
(
i
<
n
) {
12
while
(
i
<
n
&&
a
[
i
]<=
m
)
13
i
++;
14
if
(
a
[
i
] >
m
) {
15
m
=
a
[
i
];
16
nm
=
i
;
17
}
18
i
++;
19
}
20
return
nm
;
21
}
22
23
/*Testbench*/
24
25
int
main
()
26
{
27
28
int
arr
[]= {
5
,
2
,
8
,
1
,
3
,
7
,
9
,
4
};
29
int
size
=
sizeof
(
arr
) /
sizeof
(
arr
[
0
]);
30
int
result
=
m2
(
arr
,
size
);
31
32
printf
(
"Index of the maximum value in an array is: %d
\n
"
,
result
);
33
return
0
;
34
35
}