Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Napisati program koji pronalazi drugi najveci clan niza */
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, a[50], t, i, max;
- cin >> n;
- for (int i=0; i<n; i++)
- cin >> a[i];
- for (int i=n-2; i>=0; i--)
- for (int j=0; j<=i; j++)
- if (a[j] < a[j+1])
- {
- t = a[j];
- a[j] = a[j+1];
- a[j+1] = t;
- }
- i = 1;
- max = a[0];
- while (i<n)
- {
- if (a[i]==a[i-1])
- i = i + 1;
- else
- {
- max = a[i];
- i = n;
- }
- }
- if (max == a[0])
- cout << "Niz je konstantan!" << endl;
- else
- cout << max << endl;
- system ("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment