Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Finding the second largets value v0.5
//gcc 5.4.0 #include <stdio.h> #include <string.h> int main(void) { int A[5]={1,2,3,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){ if(A[j]>penval){ penval=A[j]; lpenval=j; } } } printf("The second largest number IS %d",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
Area of a rectangular prism
My first 2D array
140114_CribaErasthotenes
gcc compiler code for delay
bit shift and mask
ptr_to_ptr
20171117_FUNCIONES
linear hybrid cellular automaton utilizing rules 90 and 150 with period of (2^64)-1 for generating high quality random bits is reversible
DUE TUESDAY
Done I think