URI / BEE CROWD 1080 - Highest and Position Solution in C,C++,Python | URI - BEECROWD - BEE 1080 Solution in C,C++,Python

URI / BEE CROWD 1080 - Highest and Position Solution in C,C++,Python | URI - BEECROWD - BEE 1080 Solution in C,C++,Python

                                                                                            beecrowd | 1080

Highest and Position

Adapted by Neilor Tonin, URI  Brazil

                                                                                             Timelimit: 1


Read 100 integer numbers. Print the highest read value and the input position.

Input

The input file contains 100 distinct positive integer numbers.

Output

Print the highest number read and the input position of this value, according to the given example.

Input SampleOutput Sample

2
113
45
34565
6
...
8
 

34565
4

URI / BEE CROWD 1080 - Highest and Position Solution in C,C++,Python | URI - BEECROWD - BEE 1080 Solution in C,C++,Python

                              Demonstration:

This program takes n number of elements from the user and stores it in the arr array.

To find the largest element,the first two elements of array are checked and the largest of these two elements are placed in arr[0] .
The first and third elements are checked and largest of these two elements is placed in arr[0].
This process continues until the first and last elements are checked.The largest number will be stored in the arr[0] position and finally print the result.

N.B: Don't copy paste the code as same. Just try to understand it and try yourself.

  URI / BEE 1080 Solution in C :   

  URI / BEECROWD Online Judge 1080 Solve  in C :                                          

#include<stdio.h>

int main()
{
    int i,j = 0,p,arr[100];
    for (i = 0;i < 100;i++){
        scanf("%d", &arr[i]);
    }
    for(i = 0;i < 100;i++){
            if(arr[i] > j){
                j = arr[i];
                p = i+1;
            }
    }
    printf("%d\n", j);
    printf("%d\n", p);

    return 0;
}

0 Response to URI / BEE CROWD 1080 - Highest and Position Solution in C,C++,Python | URI - BEECROWD - BEE 1080 Solution in C,C++,Python

Post a Comment