[ create a new paste ] login | about

Link: http://codepad.org/c0vpfzPI    [ raw code | output | fork ]

C++, pasted on May 20:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
int main()
{
    const int SIZE=10;
    int v[SIZE]={1,3,2,4,6,5,7,9,8,10};
 
    int *max=v;
    for (int i=1;i<SIZE;i++)
     if(v[i]>(*max))
      max=&v[i];
 
    cout<<(max-v)+1;//номер наибольшего элемента
                    //+1 просто потому что привычнее видеть ведь элементы от 1 до 10
}


Output:
1
10


Create a new paste based on this one


Comments: