Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Finding the second largets value v0.6
//gcc 5.4.0 #include <stdio.h> #include <string.h> int main(void) { int A[5]={1,2,5,4,5}; int n=5; //n=strlen(A); int maxval=-10; int lmaxval=-10; int penval=-10; int lpenval=-10; for(int i=0;i<n;i++){ if(A[i]>maxval){ maxval=A[i]; lmaxval=i; // printf("%d=maxval\n",maxval); } // else{ // continue; // } } for(int j=0;j<n;j++){ if(j!=lmaxval&&A[j]!=maxval){ if(A[j]>penval){ penval=A[j]; lpenval=j; } } } //printf("The second largest number IS %d\n\n\n",penval); printf("%d=maxval\n%d=lmaxval\n%d=n\n%d=penval\n%d=lpenval\n",maxval,lmaxval,n,penval,lpenval); }
run
|
edit
|
history
|
help
0
formatting_input_and_output
hello world
time.c
DDD
22nd HW Switchv0.24
Valor fuera del intervalo
a3
pointer example 3
Serie de Fibonacci
A_141124Burbuja