-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolume.c
More file actions
31 lines (30 loc) · 696 Bytes
/
volume.c
File metadata and controls
31 lines (30 loc) · 696 Bytes
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
int maxArea(int* height, int heightSize) {
int maiorVolume=0, base=0, volume=0;
for(int i=0; i<heightSize; i++){
for(int j=i+1; j<heightSize; j++){
base++;
if(height[i]<=height[j]){
volume=(height[i]*base);
if(volume>maiorVolume){
maiorVolume=volume;
}
}else if(height[j]<=height[i]){
volume=(height[j]*base);
if(volume>maiorVolume){
maiorVolume=volume;
}
}
}
base=0;
}
return maiorVolume;
}
#include <stdlib.h>
#include <stdio.h>
int main(){
int tamanho=9;
int vetor[9]={1,8,6,2,5,4,8,3,7};
int retorno=maxArea(vetor, tamanho);
printf("%d", retorno);
return 0;
}