URI 1533 Solution Detective Watson - in C++ | Ad Hoc
URI Online Judge Solution 1533 Solution Detective Watson| Ad Hoc
URI Main Problem Link - 1533 Solution Detective Watson https://www.urionlinejudge.com.br/judge/en/problems/view/1533
Problem Name: URI Problem 1533 Solution Detective Watson
Problem Number : URI Problem 1533 Solution Detective Watson Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus
URI Solution 1533 Solution Detective Watson Code in CPP:
#include <iostream> #include <cstring> #include <algorithm> using namespace std; int main() { int n, x, pos; while(cin >> n && n != 0) { int array[n]; int array_copy[n]; for(int i = 0; i < n; ++i) { cin >> x; array[i] = x; } memcpy(array_copy, array, sizeof array_copy); sort(array_copy, array_copy + n); pos = array_copy[n - 2]; for(int i = 0; i < n; ++i) { if(pos == array[i]) cout << (i + 1) << endl; } } return 0; }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks