Created
September 20, 2016 13:14
-
-
Save VitorDiToro/3534c4752c018dd7ed85d28017230e35 to your computer and use it in GitHub Desktop.
Maior soma de uma subsequencia (Apenas a soma)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
int main(void) | |
{ | |
int aux = 0, soma = 0; | |
int i; | |
int vet[] = {-2,-3,4,-1,-2,1,5,-3}; | |
int n = sizeof(vet)/sizeof(int); | |
for(i=0; i<n; i++) | |
{ | |
aux = (aux + vet[i])>0 ? aux+vet[i] : aux; | |
soma = aux>soma ? aux : soma; | |
} | |
printf(" Soma = %i\n",soma); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment