Wiki User
∙ 13y agoint lastLargestIndex(int a[],int n) //a=array, n= number of elements in array
{
int max=a[0],maxp=0; //max=largest no., maxp= position of largest no.
for(int i=0;i<n;i++)
if(a[i]>=max)
{
max=a[i];
maxp=i;
}
return maxp;
}
Wiki User
∙ 13y agoAssume the first element is the largest and store its value. Then traverse the remainder of the list, one element at a time. If the current element's value is larger than the stored value, overwrite the stored value with the current element's value. Once you've traversed the list, the stored value will hold the largest value.
MAX
You have the sort() method of Javascript arrays:---var a = [1,2,10,11];a.sort(); // gives [1, 10, 11, 2]---The default sort is lexicographic, sorting the values as strings.For numbers and descending sort, you can pass in a function:---function sortNum(a, b) {return a - b;}function sortDesc(a, b) {return b - a;}a.sort(sortNum); // gives [1, 2, 10, 11]a.sort(sortDesc); // gives [11, 10, 2, 1]---The function takes two arguments, and returns a negative number if the first element is smallest, a positive number if the first element is largest, and zero if they are equal.See related link.
/* using ellipses (...) to indicate tabs for clarity */ double largest (double *array, int M, int N) { ... int i, j; ... double *element; ... double answer = array[0][0]; ... for (i=0; i<M; i++) { ... ... for (j=0; j<N; j++) { ... ... ... element = array + i*M + j; ... ... ... if (*element > answer) answer = *element; ... ... } ... } ... return answer; }
A row is just a one-dimensional array so, given a pointer to the first element of a row of doubles and the number of doubles in the row, we can use the following algorithm: // returns the largest double in an array of size count double get_largest (double * p, unsigned count) { if (p==NULL size==0) { /* invoke invalid argument handler */ } double result = *p; // store first value in row (dereference the pointer) while (--count) { // repeat for the remainder of the row ++p; // advance to the next element if (*p > result) result = *p; // if the current element is larger, update stored value } return result; // return largest value }
The element that is largest on the periodic table is Oganesson, with an atomic number of 118.
#include<stdio.h> #include<conio.h> main() { int a[100]; int n,largest,index,position; printf("enter the number of elements in the array"); scanf("%d",&n); printf("enter %d elements",n); for(index=0;index<n;index++) scanf("%d",&a[index]); largest=a[0]; position=0; for(index=1;index<n;index++) if(a[index]>largest) { largest=a[index]; position=index; } printf("largest element in the array is %d\n",largest); printf("largets element's position in the array is %d\n",position+1); getch(); }
What is the element named for the sixth-largest continent?
Iron, Fe, is the 4th largest element found on the lithosphere.
The largest human organ is the skin and it's function is to protect you.
The largest natural stable element is bismuth with atomic number 83. It is the heaviest element that is stable and does not undergo radioactive decay.
Element hassium has the largest Atomic Mass.
francium has the largest ionic radius
Fluorine (F) has the largest oxidation number of +7.
Radon
{4/5, 41/50, 17/20, 75%} The Element Largest Value Is?
The element Europium was named after the continent of Europe, the 1st largest continent in terms of land area.